Fixes to migration of local store from old Master Password model persistence models.
This commit is contained in:
parent
40d6019f71
commit
07dd98823f
2
External/UbiquityStoreManager
vendored
2
External/UbiquityStoreManager
vendored
@ -1 +1 @@
|
||||
Subproject commit fb1b53869cee17efcc5b5a3b4232392fb006c463
|
||||
Subproject commit 6707cb36233c9f6b7c2a71c8aa186ccf11bd318f
|
@ -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.");
|
||||
|
Loading…
Reference in New Issue
Block a user