2
0

Fix migration problems non-interactively.

[FIXED]     Migration problems should be fixed non-interactively: The
            main thread may well be unavailable which means we may not
            be able to actually get a message through to the user.  This
            would dead-lock the migration problem recovery.
This commit is contained in:
Maarten Billemont 2012-05-09 23:36:45 +02:00
parent c8f9f79bb2
commit db7d68a091
3 changed files with 14 additions and 17 deletions

@ -1 +1 @@
Subproject commit b456a34975e65fba8e2228b790706d852188ecb2
Subproject commit 71cfb8f4e21a536f5d88a69401f02eeaf1c0a89f

View File

@ -181,11 +181,6 @@ static NSDateFormatter *rfc3339DateFormatter = nil;
dbg(@"StoreManager: %@", message);
}
- (void)ubiquityStoreManager:(UbiquityStoreManager *)manager didEncounterError:(NSError *)error cause:(UbiquityStoreManagerErrorCause)cause context:(id)context {
err(@"StoreManager: cause=%d, context=%@, error=%@", cause, context, error);
}
#pragma mark - Import / Export
- (void)loadRFC3339DateFormatter {

View File

@ -396,30 +396,32 @@
#pragma mark - UbiquityStoreManagerDelegate
- (void)ubiquityStoreManager:(UbiquityStoreManager *)manager didSwitchToiCloud:(BOOL)didSwitch {
inf(@"didSwitchToiCloud: %d", didSwitch);
}
- (void)ubiquityStoreManager:(UbiquityStoreManager *)manager didEncounterError:(NSError *)error cause:(UbiquityStoreManagerErrorCause)cause context:(id)context {
err(@"StoreManager: cause=%d, context=%@, error=%@", cause, context, error);
switch (cause) {
case UbiquityStoreManagerErrorCauseDeleteStore:
case UbiquityStoreManagerErrorCauseDeleteLogs:
case UbiquityStoreManagerErrorCauseCreateStorePath:
case UbiquityStoreManagerErrorCauseClearStore:
break;
case UbiquityStoreManagerErrorCauseOpenLocalStore: {
[PearlAlert showError:@"Could not open your local database.\n\n"
@"The database may be too old. It will be deleted, the application will quit, "
@"and on the next launch a fresh database will be created." tappedButtonBlock:^(UIAlertView *alert, NSInteger buttonIndex) {
wrn(@"Local store could not be opened, deleting it.");
[[NSFileManager defaultManager] removeItemAtURL:context error:nil];
exit(0);
} otherTitles:nil];
wrn(@"Local store could not be opened, resetting it.");
manager.hardResetEnabled = YES;
[manager hardResetLocalStorage];
exit(1);
break;
}
case UbiquityStoreManagerErrorCauseOpenCloudStore: {
[PearlAlert showError:@"Could not use iCloud-synced storage. Will use a local database for now.\n\n"
@"If this problem persists, you may need to reset your Master Password database on iCloud."];
wrn(@"iCloud store could not be opened, moving to local store.");
[manager useiCloudStore:NO alertUser:NO];
wrn(@"iCloud store could not be opened, resetting it.");
manager.hardResetEnabled = YES;
[manager hardResetCloudStorage];
break;
}
}