From b86e1c9993b7d0068eb29e9807bb62f6bdb00739 Mon Sep 17 00:00:00 2001 From: cramakri <cramakri> Date: Thu, 1 Nov 2012 12:17:35 +0000 Subject: [PATCH] Have startup code delete the local cache if the cache cannot be opened anymore. This is usually because of a change to the DB model during development. SVN: 27455 --- openbis-ipad/openBIS/openBIS/CISDOBAppDelegate.m | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/openbis-ipad/openBIS/openBIS/CISDOBAppDelegate.m b/openbis-ipad/openBIS/openBIS/CISDOBAppDelegate.m index 856f25ef26b..49f69b9234b 100644 --- a/openbis-ipad/openBIS/openBIS/CISDOBAppDelegate.m +++ b/openbis-ipad/openBIS/openBIS/CISDOBAppDelegate.m @@ -135,6 +135,7 @@ if (_serviceManager) return _serviceManager; NSURL *storeUrl = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"openBISData.sqlite"]; + NSURL *openbisUrl = [self openbisUrl]; NSError *error; @@ -143,9 +144,17 @@ initWithStoreUrl: storeUrl openbisUrl: openbisUrl trusted: YES error: &error]; if (!_serviceManager) { - // TODO Implement error handling - NSLog(@"Unresolved error -- could not create service manager %@, %@", error, [error userInfo]); - abort(); + // We couldn't open the store, probably because we changed the database model. Remove the old cache and create the service manager again. + [[NSFileManager defaultManager] removeItemAtURL: storeUrl error: nil]; + + _serviceManager = + [[CISDOBIpadServiceManager alloc] + initWithStoreUrl: storeUrl openbisUrl: openbisUrl trusted: YES error: &error]; + if (_serviceManager) { + // TODO Implement error handling + NSLog(@"Unresolved error -- could not create service manager %@, %@", error, [error userInfo]); + abort(); + } } return _serviceManager; -- GitLab