From 07dd98823f3191948f1024814c2cdbd2f04d58c8 Mon Sep 17 00:00:00 2001 From: Maarten Billemont Date: Mon, 16 Sep 2013 23:18:01 -0400 Subject: [PATCH] Fixes to migration of local store from old Master Password model persistence models. --- External/UbiquityStoreManager | 2 +- MasterPassword/ObjC/MPAppDelegate_Store.m | 59 +++-------------------- 2 files changed, 7 insertions(+), 54 deletions(-) diff --git a/External/UbiquityStoreManager b/External/UbiquityStoreManager index fb1b5386..6707cb36 160000 --- a/External/UbiquityStoreManager +++ b/External/UbiquityStoreManager @@ -1 +1 @@ -Subproject commit fb1b53869cee17efcc5b5a3b4232392fb006c463 +Subproject commit 6707cb36233c9f6b7c2a71c8aa186ccf11bd318f diff --git a/MasterPassword/ObjC/MPAppDelegate_Store.m b/MasterPassword/ObjC/MPAppDelegate_Store.m index 444c9814..3895422d 100644 --- a/MasterPassword/ObjC/MPAppDelegate_Store.m +++ b/MasterPassword/ObjC/MPAppDelegate_Store.m @@ -246,27 +246,10 @@ PearlAssociatedObjectProperty(NSManagedObjectContext*, MainManagedObjectContext, return YES; } - NSError *error = nil; - NSDictionary *oldLocalStoreOptions = @{ - STORE_OPTIONS - NSReadOnlyPersistentStoreOption : @YES, - NSInferMappingModelAutomaticallyOption : @YES - }; - NSDictionary *newLocalStoreOptions = @{ - STORE_OPTIONS - NSMigratePersistentStoresAutomaticallyOption : @YES, - NSInferMappingModelAutomaticallyOption : @YES - }; - // Create the directory to hold the new local store. - if (![[NSFileManager defaultManager] createDirectoryAtPath:[self.storeManager URLForLocalStoreDirectory].path - withIntermediateDirectories:YES attributes:nil error:&error]) - err(@"While creating directory for new local store: %@", error); - - if (![self.storeManager migrateStore:oldLocalStoreURL withOptions:oldLocalStoreOptions - toStore:newLocalStoreURL withOptions:newLocalStoreOptions - strategy:self.storeManager.migrationStrategy - error:nil cause:nil context:nil]) { + if (![self.storeManager migrateStore:oldLocalStoreURL withOptions:nil + toStore:newLocalStoreURL withOptions:nil + strategy:0 error:nil cause:nil context:nil]) { self.storeManager.localStoreURL = oldLocalStoreURL; return NO; } @@ -283,39 +266,9 @@ PearlAssociatedObjectProperty(NSManagedObjectContext*, MainManagedObjectContext, } NSURL *newCloudStoreURL = [self.storeManager URLForCloudStore]; - NSURL *newCloudContentURL = [self.storeManager URLForCloudContent]; - - NSError *error = nil; - NSDictionary *oldCloudStoreOptions = @{ - STORE_OPTIONS - NSPersistentStoreUbiquitousContentNameKey : contentName, - NSPersistentStoreUbiquitousContentURLKey : oldCloudContentURL, - NSInferMappingModelAutomaticallyOption : @YES - }; - NSDictionary *newCloudStoreOptions = @{ - STORE_OPTIONS - NSPersistentStoreUbiquitousContentNameKey : [self.storeManager valueForKey:@"contentName"], - NSPersistentStoreUbiquitousContentURLKey : newCloudContentURL, - NSMigratePersistentStoresAutomaticallyOption : @YES, - NSInferMappingModelAutomaticallyOption : @YES - }; - - // Create the directory to hold the new cloud store. - // This is only necessary if we want to try to rebuild the old store. See comment above about how that failed. - if (![[NSFileManager defaultManager] createDirectoryAtPath:[oldCloudStoreURL URLByDeletingLastPathComponent].path - withIntermediateDirectories:YES attributes:nil error:&error]) - err(@"While creating directory for old cloud store: %@", error); - if (![[NSFileManager defaultManager] createDirectoryAtPath:oldCloudContentURL.path - withIntermediateDirectories:YES attributes:nil error:&error]) - err(@"While creating directory for old cloud content: %@", error); - if (![[NSFileManager defaultManager] createDirectoryAtPath:[self.storeManager URLForCloudStoreDirectory].path - withIntermediateDirectories:YES attributes:nil error:&error]) - err(@"While creating directory for new cloud store: %@", error); - - if (![self.storeManager migrateStore:oldCloudStoreURL withOptions:oldCloudStoreOptions - toStore:newCloudStoreURL withOptions:newCloudStoreOptions - strategy:self.storeManager.migrationStrategy - error:nil cause:nil context:nil]) + if (![self.storeManager migrateStore:oldCloudStoreURL withOptions:nil + toStore:newCloudStoreURL withOptions:nil + strategy:0 error:nil cause:nil context:nil]) return NO; inf(@"Successfully migrated to new cloud store.");