Fixed issue when trying to store key files for drafted documents

This commit is contained in:
Michael Starke
2022-05-24 11:46:17 +02:00
parent 8be69ca779
commit cbb4cea9cf

View File

@@ -969,12 +969,18 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou
} }
- (void)_storeKeyURL:(NSURL *)keyURL { - (void)_storeKeyURL:(NSURL *)keyURL {
if(self.isDraft) {
// we cannot store key files for draft documents
return;
}
NSMutableDictionary *keysForFiles = [[NSUserDefaults.standardUserDefaults dictionaryForKey:kMPSettingsKeyRememeberdKeysForDatabases] mutableCopy]; NSMutableDictionary *keysForFiles = [[NSUserDefaults.standardUserDefaults dictionaryForKey:kMPSettingsKeyRememeberdKeysForDatabases] mutableCopy];
MPAppDelegate *delegate = (MPAppDelegate *)[NSApp delegate]; MPAppDelegate *delegate = (MPAppDelegate *)[NSApp delegate];
if(!delegate.isAllowedToStoreKeyFile || nil == keyURL) { if(!delegate.isAllowedToStoreKeyFile || nil == keyURL) {
/* user has removed the keyfile or we should not safe it so remove it */ /* user has removed the keyfile or we should not safe it so remove it */
if(self.fileURL) {
[keysForFiles removeObjectForKey:self.fileURL.path.sha1HexDigest]; [keysForFiles removeObjectForKey:self.fileURL.path.sha1HexDigest];
} }
}
else if([self.compositeKey hasKeyOfClass:KPKPasswordKey.class] && [self.compositeKey hasKeyOfClass:KPKFileKey.class]) { else if([self.compositeKey hasKeyOfClass:KPKPasswordKey.class] && [self.compositeKey hasKeyOfClass:KPKFileKey.class]) {
if(nil == keysForFiles) { if(nil == keysForFiles) {
keysForFiles = [[NSMutableDictionary alloc] initWithCapacity:1]; keysForFiles = [[NSMutableDictionary alloc] initWithCapacity:1];