On Jan 2, 2018, at 12:31 AM, Brendan Duddridge <bren...@gmail.com> wrote:Jan 1 22:18:22 iPhone-X Tap Forms[11762] <Notice>: Error opening Tap Forms database: Error Domain=CBLHTTP Code=400 "Invalid database/document/revision ID" UserInfo={NSLocalizedFailureReason=Invalid database/document/revision ID, NSLocalizedDescription=Invalid database/document/revision ID}
I thought just using NSFileProtectionCompleteUntilFirstUserAuthentication for the Data Protection mode would suffice, but it doesn't appear to be so.
The error message refers to opening the database, but your email implies the database is already open. Do you know which API call this error is returned from? And is anything being logged before this error?This isn’t the error I’d expect when the filesystem is locked. In 1.4 and 1.4.1, Pasin and I added code to detect those filesystem/SQLite errors and return appropriate CBL errors (I think it’s 401.)
NSError *error = nil;
CBLDatabaseOptions *options = [[CBLDatabaseOptions alloc] init];
// options.storageType = kCBLForestDBStorage;
// options.storageType = kCBLSQLiteStorage;
options.encryptionKey = self.encryptionKey;
options.create = YES;
BOOL databaseExists = [self.couchManager databaseExistsNamed:dbName];
self.couchDatabase = [self.couchManager openDatabaseNamed:dbName
withOptions:options
error:&error];
if (error && error.code == 401) {
// database file is encrypted. Ask for a key.
self.isDatabaseEncrypted = YES;
self.documentIsLocked = YES;
} else if (error || !self.couchDatabase) {
The file is stored in an encrypted format on disk and cannot be accessed until after the device has booted. After the user unlocks the device for the first time, your app can access the file and continue to access it even if the user subsequently locks the device.
if (error && error.code == 401) {
// ...trimmed...
} else if (error || !self.couchDatabase) {NSLog(@"Error opening Tap Forms database: %@", error);
if (!self.couchDatabase) {if (error.code == 401) {…} else {
NSLog(@"Error opening Tap Forms database: %@", error);}}
NSError *error = nil;
But I've just reworked it as you suggested, so I'll see if that solves the problem.
Thanks!
Brendan