From c0c053d4222b4664f0dec64f7862c9d7d6193135 Mon Sep 17 00:00:00 2001 From: Michael Starke Date: Tue, 27 Aug 2019 14:54:00 +0200 Subject: [PATCH] Retain custom file extension if present and do not change back to .kdbx (or .kdb) --- MacPass/MPDocument.m | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/MacPass/MPDocument.m b/MacPass/MPDocument.m index 574bff14..0034cc01 100644 --- a/MacPass/MPDocument.m +++ b/MacPass/MPDocument.m @@ -173,6 +173,18 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou return NO; } +- (NSString *)fileNameExtensionForType:(NSString *)typeName saveOperation:(NSSaveOperationType)saveOperation { + NSString *proposedExtension = [super fileNameExtensionForType:typeName saveOperation:saveOperation]; + if(!self.fileURL) { + return proposedExtension; + } + NSString *actualExtension = self.fileURL.pathExtension; + if(![actualExtension isEqualToString:proposedExtension]) { + NSLog(@"Extension missmatch."); + } + return actualExtension; +} + - (NSData *)dataOfType:(NSString *)typeName error:(NSError * _Nullable __autoreleasing *)outError { if(self.encrypted) { NSLog(@"%@ should not be called on locked databases!", NSStringFromSelector(_cmd));