only save database on lock if file was acutally changed. Otherweise leave it be.

This commit is contained in:
michael starke
2017-11-27 18:59:18 +01:00
parent 32a1f10910
commit 4628c638a8
3 changed files with 10 additions and 5 deletions

View File

@@ -1,3 +1,3 @@
github "sparkle-project/Sparkle" ~> 1.18.1
github "MacPass/KeePassKit" ~> 1.8
github "MacPass/KeePassKit" ~> 1.9
github "mstarke/HNHUi" ~> 1.4.1

View File

@@ -1,3 +1,3 @@
github "MacPass/KeePassKit" "1.8"
github "MacPass/KeePassKit" "1.9"
github "mstarke/HNHUi" "1.4.1"
github "sparkle-project/Sparkle" "1.18.1"

View File

@@ -417,8 +417,13 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou
for(NSWindow *sheet in [self windowForSheet].sheets) {
[[self windowForSheet] endSheet:sheet];
}
if(self.documentEdited) {
[self saveDocumentWithDelegate:self didSaveSelector:@selector(_lockDatabaseForDocument:didSave:contextInfo:) contextInfo:NULL];
}
else {
[self _lockDatabaseForDocument:self didSave:YES contextInfo:NULL];
}
}
}
- (void)_lockDatabaseForDocument:(NSDocument *)document didSave:(BOOL)didSave contextInfo:(void *)contextInfo {
@@ -433,8 +438,8 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou
[self exitSearch:self];
[self.undoManager removeAllActions];
NSError *error;
/* TODO let the tree chose the encryption */
self.encryptedData = [self.tree encryptWithKey:self.compositeKey format:[MPDocument formatForFileType:self.fileType] error:&error];
/* use data from disk since we wrote it*/
self.encryptedData = [NSData dataWithContentsOfURL:self.fileURL options:NSDataReadingUncached error:&error];
if(nil == self.encryptedData && error ) {
[self presentError:error];
return;