-
Notifications
You must be signed in to change notification settings - Fork 40
Conversation
Build currently failing because new certificates need to be uploaded to buddybuild. Resolving on Monday. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good!
enum DatabaseError: Error { | ||
case issueDeletingDatabase(description: String) | ||
case issueCreatingDatabase(description: String) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏
} | ||
|
||
private func createNewDatabase() throws { | ||
guard let encryptionKey = loginsKey else { throw DatabaseError.issueCreatingDatabase(description: "logins database key is nil") } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good! I'd be even happier if we had a minimal AlertDialog
shown if and only if out error recovery errored or detected something we weren't able to recover from (i.e. returned nil
).
Well done for fixing this long standing bug!
@@ -487,19 +491,59 @@ extension BaseDataStore { | |||
guard let db = loginsStorage as? LoginsStorage else { | |||
return createRandomSalt() | |||
} | |||
|
|||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: whitespace
Shared/Store/BaseDataStore.swift
Outdated
|
||
do { | ||
try loginsStorage.ensureUnlockedWithKeyAndSalt(key: loginsKey, salt: salt) | ||
self.storageStateSubject.onNext(.Unlocked) | ||
} catch let error as LoginsStoreError { | ||
pushError(error) | ||
// If we can not access database with current salt and key, need to delete local database and migrate to replacement salt | ||
// This only deletes the local database file, does not delete the user's sync data | ||
_ = handleDatabaseAccessFailure(databasePath: loginsDatabasePath, encryptionKey: loginsKey) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we fail in this method, what happens? e.g. if we throw an unexpected runtime exception, or if the app can't continue, perhaps we could fail more loudly (e.g. alert) than a crash?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this fails - maybe I could fire off a reset action from within the handleDatabaseAccessFailure function? I actually changed this so that handleDatabaseAccessFailure doesn't return, as it didn't need to since the salt gets stored locally in the keychain.
Fixes #1201
Database salt and plain text header migration failed for certain users with the update of 1.7.2, which left their app in an unusable state as the database was not accessible. This PR resolves those issues and resets the local database without deleting any user sync data.