views:

23

answers:

1

I am getting the following error from some users while performing a lightweight Core Data migration on iPhone:

{
NSUnderlyingError = Error Domain=NSPOSIXErrorDomain Code=17 UserInfo=0x2991d0
"Operation could not be completed. File exists";
destinationURL = file://localhost/var/mobile/Applications/AEFD8CE2-0AF6-4227-AB84-73E2F5D83F26/Documents/App.sqlite.new;
reason = "Can't copy source store to destination store path";
sourceURL = file://localhost/var/mobile/Applications/AEFD8CE2-0AF6-4227-AB84-73E2F5D83F26/Documents/App.sqlite;
}

Is this the result of an interrupted migration? Or some other cause? In any case, is the appropriate remedy to manually delete the .new database before attempting to migrate?

The code is just a simple lightweight migration:

NSURL *storeUrl = [NSURL fileURLWithPath: [[self applicationDocumentsDirectory] stringByAppendingPathComponent: @"App.sqlite"]];
NSError *error = nil;
persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
// convert automatically from prior models
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
                         [NSNumber numberWithBool:YES], 
                         NSMigratePersistentStoresAutomaticallyOption,
                         [NSNumber numberWithBool:YES],
                         NSInferMappingModelAutomaticallyOption,
                         nil];
if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl options:options error:&error]) 
{
    [MainAppDelegate printDetailedErrors:error];
}

UPDATE: BenT from the Apple forums tells me this is a 3.1.x bug, but I haven't yet gone back and verified this with my error log data.

A: 

Core Data does not routinely name files .new. Can you show the code that is generating this error?

update

If the BenT says it is a bug then that is the answer. If anyone has the answer to a Core Data question, Ben does.

Marcus S. Zarra
Sure, post edited.
sehugg