From 6555cc04e54fdbc5c85eca53e60f865246604c26 Mon Sep 17 00:00:00 2001 From: Michael Starke Date: Sat, 25 Aug 2018 08:48:35 +0200 Subject: [PATCH] Merging KDB files with different options to prevent group duplication --- Cartfile | 2 +- Cartfile.resolved | 2 +- MacPass/Base.lproj/DatabaseSettingsWindow.xib | 6 +++--- MacPass/MPDocument.m | 11 ++++++++++- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Cartfile b/Cartfile index 1b7b1db1..73ef5287 100644 --- a/Cartfile +++ b/Cartfile @@ -1,3 +1,3 @@ github "sparkle-project/Sparkle" ~> 1.18.1 -github "MacPass/KeePassKit" ~> 1.13.5 +github "MacPass/KeePassKit" ~> 1.13.6 github "mstarke/HNHUi" ~> 1.5 diff --git a/Cartfile.resolved b/Cartfile.resolved index e0c8231f..8e9ed6d8 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,4 +1,4 @@ -github "MacPass/KeePassKit" "1.13.5" +github "MacPass/KeePassKit" "1.13.6" github "mstarke/HNHUi" "1.5" github "robbiehanson/KissXML" "5.2.3" github "sparkle-project/Sparkle" "1.19.0" diff --git a/MacPass/Base.lproj/DatabaseSettingsWindow.xib b/MacPass/Base.lproj/DatabaseSettingsWindow.xib index d65c8f66..b1514ec3 100644 --- a/MacPass/Base.lproj/DatabaseSettingsWindow.xib +++ b/MacPass/Base.lproj/DatabaseSettingsWindow.xib @@ -52,7 +52,7 @@ - + @@ -498,8 +498,8 @@ Gw - - + + diff --git a/MacPass/MPDocument.m b/MacPass/MPDocument.m index efb2352c..ab0eea2f 100644 --- a/MacPass/MPDocument.m +++ b/MacPass/MPDocument.m @@ -359,14 +359,23 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou NSError *error; KPKTree *otherTree; + BOOL mergeKDB; + /* TODO determine KDB file format to set GroupByTitle options */ + + KPKFileVersion version = [KPKFormat.sharedFormat fileVersionForData:[NSData dataWithContentsOfURL:url]]; + mergeKDB = (version.format == KPKDatabaseFormatKdb); if(key) { otherTree = [[KPKTree alloc] initWithContentsOfUrl:url key:key error:&error]; } if(otherTree) { - [self.tree synchronizeWithTree:otherTree mode:KPKSynchronizationModeSynchronize options:0]; + KPKSynchronizationOptions options = 0; + if(mergeKDB) { + options |= KPKSynchronizationOptionMatchGroupsByTitleOnly; + } + [self.tree synchronizeWithTree:otherTree mode:KPKSynchronizationModeSynchronize options:options]; /* the key might have changed so update ours! */ //self.compositeKey = key; [self updateChangeCount:NSChangeDone];