From cbb4cea9cfd697a97f800f51769fc619158ad4bf Mon Sep 17 00:00:00 2001 From: Michael Starke Date: Tue, 24 May 2022 11:46:17 +0200 Subject: [PATCH] Fixed issue when trying to store key files for drafted documents --- MacPass/MPDocument.m | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/MacPass/MPDocument.m b/MacPass/MPDocument.m index 5a7d5187..3197723e 100644 --- a/MacPass/MPDocument.m +++ b/MacPass/MPDocument.m @@ -969,11 +969,17 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou } - (void)_storeKeyURL:(NSURL *)keyURL { + if(self.isDraft) { + // we cannot store key files for draft documents + return; + } NSMutableDictionary *keysForFiles = [[NSUserDefaults.standardUserDefaults dictionaryForKey:kMPSettingsKeyRememeberdKeysForDatabases] mutableCopy]; MPAppDelegate *delegate = (MPAppDelegate *)[NSApp delegate]; if(!delegate.isAllowedToStoreKeyFile || nil == keyURL) { /* user has removed the keyfile or we should not safe it so remove it */ - [keysForFiles removeObjectForKey:self.fileURL.path.sha1HexDigest]; + if(self.fileURL) { + [keysForFiles removeObjectForKey:self.fileURL.path.sha1HexDigest]; + } } else if([self.compositeKey hasKeyOfClass:KPKPasswordKey.class] && [self.compositeKey hasKeyOfClass:KPKFileKey.class]) { if(nil == keysForFiles) {