• 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: NSDocument save incremental file package in-place
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSDocument save incremental file package in-place


  • Subject: Re: NSDocument save incremental file package in-place
  • From: Trygve Inda <email@hidden>
  • Date: Sat, 01 Mar 2014 11:11:13 -0800
  • Thread-topic: NSDocument save incremental file package in-place

> On Mar 1, 2014, at 07:23 , Trygve Inda <email@hidden> wrote:
>
>> The problem is that when there is a very small change (just adding or
>> removing one of the files in the package), the system does not save in
>> place.
>>
>> Rather it reads the previous package file completely, writes out a copy of
>> the package (400 MB) and then renames it.
>>
>> How can I get it to save in place?
>
> AFAIK, NSDocument never saves in place, and isn’t intended to (for safety
> reasons — what happens if your app crashes after some of the files have been
> updated but not others?).
>
> Instead, it achieves its package performance optimization by hard-linking
> unchanged files in the new (saved) package to files in the old (original)
> package. If your save is taking 40 seconds, that could mean:
>
> — The document is on a file system that doesn’t support hard linking.
>
> — The document is on a file system where hard linking 7500 files takes 40
> seconds.
>
> — You didn’t preserve the original file sub-wrappers from the directory
> wrapper created when the document was opened, so NSDocument thinks all the
> files have changed. Note that it’s undocumented (again, AFAIK) what criteria
> NSDocument uses** to decide when a particular file wrapper represents “no
> change”, so it’s safest to keep the original NSFileWrapper objects from open
> time until save time.
>
>
>
> ** The most likely possibilities are ‘==’ on file wrappers, ‘isEqual:’ on file
> wrappers, or comparison of mod date and/or size of the actual files, but it
> could be something more obscure.
>


When a file is opened, my NSDocument subclass uses

-(BOOL)readFromFileWrapper:(NSFileWrapper *)fileWrapper ofType:(NSString
*)typeName error:(NSError **)outError

After loading it, I call

[self setDocumentFileWrapper:fileWrapper];

Which stores the fileWrapper in my Document object for later use.


Later, when saving I use

-(NSFileWrapper *)fileWrapperOfType:(NSString *)typeName error:(NSError
**)outError

Even if I only call

return documentFileWrapper;

So the document is saved with zero changes, it takes 40 seconds on my
package with 7500 sub-items. It should happen almost instantly, but it
doesn't.

I am using a normal Mac HFS system.

I really need this to be faster.

Trygve




_______________________________________________

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: NSDocument save incremental file package in-place
      • From: Mike Abdullah <email@hidden>
References: 
 >Re: NSDocument save incremental file package in-place (From: Quincey Morris <email@hidden>)

  • Prev by Date: Re: NSDocument save incremental file package in-place
  • Next by Date: Re: NSDocument save incremental file package in-place
  • Previous by thread: Re: NSDocument save incremental file package in-place
  • Next by thread: Re: NSDocument save incremental file package in-place
  • Index(es):
    • Date
    • Thread