Re: NSPersistentDocument Migration with Sandbox
Re: NSPersistentDocument Migration with Sandbox
- Subject: Re: NSPersistentDocument Migration with Sandbox
- From: Jerry Krinock <email@hidden>
- Date: Fri, 10 May 2013 07:12:55 -0700
On 2013 May 09, at 23:26, Jim McGowan <email@hidden> wrote:
> Core Data document migration will try to write the migrated store to the same directory as the original, but the sandbox blocks this.
I think that it would help to have a higher-level understanding of the problem. How about this…
You have a sandboxed app in which the user has somehow opened a document outside your sandbox (because the user navigated to it in an Open dialog?). I think that if migration was not required, the user could edit the document and click File > Save, and sandboxd would allow your user to re-save the document outside your sandbox, because it was there to begin with (is that correct?) But Core Data writes temporary files during migrations in the document's directory, which is not allowed.
This appears to be edge-case oversight in Apple's sandboxing design. Either Core Data should write its temporary files (and tilde files) to an allowed location within your sandbox, or sandboxd should allow Core Data to do write these files in whatever directory the document currently resides.
Have I stated this correctly?
In the meantime, you need a workaround for this bug. An ugly solution would be to override the migration methods, test if a file can be written in the document's directory before migration begins, and if not, inform the user that the document must be moved into the sandbox so that it can be updated. This might not be too bad if users rarely open documents outside your sandbox. Otherwise, well, I would throw this one at Apple. DTS incidents are pretty cheap nowadays, the problem is clear, and I've already written it up for you :)
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden