On May 23, 2010, at 18:11, Jerry Krinock wrote:

> To perform Core Data migration automaticlly, my overridden 
> configurePersistentStoreCoordinatorForURL:ofType:modelConfiguration:storeOptions:error:,
>  archives the original document by invoking -[NSFileManager 
> moveItemAtPath:::], appending a tilde (~) to its name, then migrates the 
> document to a new store/file, and similarly moves the new file back to the 
> original name and opens it. 

Aren't you kicking the ladder out from under yourself here? In regard to 
NSDocument, I mean, not the Core Data part.

Having thrown the document's file aside, it doesn't seem terribly surprising 
that the document would get upset if it gets a chance to notice. (In fact, I 
assume you must be calling setFileURL later yourself, after the migration, to 
prevent the document from complaining that "the" file's mod date has changed.)

Why would you not defer renaming the old file until after the migration, then 
move the files around all at once?

BTW, even that's not safe because events outside your control (like a crash or 
other forced termination) can occur in the middle of all the file moving and 
renaming. That's why FSExchangeFiles (or whatever has since supplanted it) was 
introduced, and it still seems like the superior solution in cases like this, 
where one file is assuming another's identity.


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to