• 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: How to Versions Browser when document won't open?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to Versions Browser when document won't open?


  • Subject: Re: How to Versions Browser when document won't open?
  • From: Jerry Krinock <email@hidden>
  • Date: Fri, 21 Mar 2014 00:15:59 -0700

It looks like we have a solution to the problem of the user not being able to restore a corrupt document from Versions Browser because the document is corrupt, and so she can’t open it, and so she can’t File > Revert to > Browse All Versions.

The solution is:

• Override -[NSDocument openDocumentWithContentsOfURL:display:error:].
• After invoking super, look in returned error for SQLite error code:11, 'database disk image is malformed’.
• If that error is found, clear all data from the document on the disk.
• In its place, copy in data from a good, empty document.
• Invoke super again.  The document will open this time.
• Display a sheet informing user that document was corrupt and suggest File > Revert to > Browse All Versions.

I’ve not written the code yet, just done the above manually with a Core Data SQLite document that has legacy Delete/Rollback journaling.  Corruption was simulated by punching out the middle of the file with a hex editor.  I also used a hex editor to nuke and pave the document.  Result: Versions Browser showed previous versions of the corrupted document, as desired.  After restoring one, I was able to edit, save, close, and re-open it and nothing complained.

Happily, no reverse engineering of /.DocumentRevisions-V100 was necessary, but I’m still open to any better ideas.  Did I miss an easier solution to this problem that is built into Cocoa?

I’m aware that the magic in NS(Persistent)Document often comes back to bite with a vengeance days or weeks later.  I shall post again if I have any trouble.


_______________________________________________

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


References: 
 >How to Versions Browser when document won't open? (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Re: Animation on gesturing
  • Next by Date: Simulating sublayers in CATiledLayer
  • Previous by thread: How to Versions Browser when document won't open?
  • Next by thread: Simulating sublayers in CATiledLayer
  • Index(es):
    • Date
    • Thread