Fixed error that resulted in always trying to save a key file even if none was used

This commit is contained in:
michael starke
2013-11-30 19:31:32 +01:00
parent 871b3a5c45
commit 36e493101a
2 changed files with 5 additions and 2 deletions

View File

@@ -250,7 +250,7 @@ typedef NS_ENUM(NSUInteger, MPAlertType) {
if(isUnlocked) {
[[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentDidUnlockDatabaseNotification object:self];
/* Make sure to only store */
if(self.compositeKey.hasPassword && self.isAllowedToStoreKeyFile) {
if(self.compositeKey.hasKeyFile && self.compositeKey.hasPassword && self.isAllowedToStoreKeyFile) {
[self _storeKeyURL:keyFileURL];
}
}
@@ -565,6 +565,9 @@ typedef NS_ENUM(NSUInteger, MPAlertType) {
}
- (void)_storeKeyURL:(NSURL *)keyURL {
if(nil == keyURL) {
return; // no URL to store in the first place
}
NSAssert(self.isAllowedToStoreKeyFile, @"We can only store if we are allowed to do so!");
NSMutableDictionary *keysForFiles = [[[NSUserDefaults standardUserDefaults] dictionaryForKey:kMPSettingsKeyRememeberdKeysForDatabases] mutableCopy];
if(nil == keysForFiles) {