• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Storing NSDocument data in packages/bundles
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Storing NSDocument data in packages/bundles


  • Subject: Re: Storing NSDocument data in packages/bundles
  • From: Markus Spoettl <email@hidden>
  • Date: Wed, 31 Dec 2008 10:12:56 -0800

On Dec 31, 2008, at 4:46 AM, Quincey Morris wrote:
I don't see how trying to do this in - writeToURL:ofType:forSaveOperation:originalContentsURL:error: is ever going to work.

If you are given (basically) an old and new package location, then you're forced to copy everything:

-- Trying to write changed files in the old location would be a really bad idea.

-- Moving the unchanged files from the old location to the new location would probably work (if the save operation is a pure save, not a save-as or save-to), but would be a really bad idea if there was an error during the save (because the contents of the new location would presumably get thrown away).

The *real* question here is: what's a *safe* strategy for saving a package by changing parts of it? You really need a single atomic operation to commit the changes, and most file systems don't provide this for an arbitrary set of files. NSDocument's answer is that there isn't a safe strategy, so it always saves by creating a copy. (And even that's not perfectly safe if the file system doesn't provide the equivalent of FSSwapFiles.)

Using Core Data as the storage mechanism for blobs of data is a possibility, but it's also a PITA because:

-- you likely need to turn off NSPersistentDocument's undo handling and provide your own

-- Core Data doesn't have save-to, and its save-as sucks (does a store migration)

-- if you have a lot of data, Core Data is going to keep copies of much of it in internal caches

My suggestion would be to go ahead and use a package document format, and to copy the unchanged files, and see how long it takes. If the save times are unacceptable, then a database solution (not Core Data) is probably the next step.


Thanks for the pointers, I'll think about that. It's rather surprising that NSDocument's save-as-copy-and-move strategy that works so well for single files backfires so heavily in my case.

Regards
Markus
--
__________________________________________
Markus Spoettl

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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

  • Follow-Ups:
    • Re: Storing NSDocument data in packages/bundles
      • From: Quincey Morris <email@hidden>
References: 
 >Storing NSDocument data in packages/bundles (From: Markus Spoettl <email@hidden>)
 >Re: Storing NSDocument data in packages/bundles (From: "Kyle Sluder" <email@hidden>)
 >Re: Storing NSDocument data in packages/bundles (From: Markus Spoettl <email@hidden>)
 >Re: Storing NSDocument data in packages/bundles (From: "Kyle Sluder" <email@hidden>)
 >Re: Storing NSDocument data in packages/bundles (From: Quincey Morris <email@hidden>)

  • Prev by Date: Re: Storing NSDocument data in packages/bundles
  • Next by Date: Re: modifier key query
  • Previous by thread: Re: Storing NSDocument data in packages/bundles
  • Next by thread: Re: Storing NSDocument data in packages/bundles
  • Index(es):
    • Date
    • Thread