Skip to content
Snippets Groups Projects
Commit b86e1c99 authored by cramakri's avatar cramakri
Browse files

Have startup code delete the local cache if the cache cannot be opened...

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
parent c589bb9e
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment