-saveDocument: and package problems
-saveDocument: and package problems
- Subject: -saveDocument: and package problems
- From: Keith Blount <email@hidden>
- Date: Tue, 19 Feb 2008 09:28:00 -0800 (PST)
Hi,
I've had a couple of reports of serious data loss in my app and am stumped. I'm wondering if anyone here might have any ideas; perhaps I have made a bad assumption somewhere.
My app uses a package format to save its data - a regular folder (but with an extension and icon, obviously) containing a bunch of RTFD files (the text documents that can be opened by my app) and a saved dictionary file containing a structured list of these files for the source list.
I open the package using NSDocument's - readFromURL:ofType:error:. In this method I just look for the dictionary file and get information from that, and load into the editor the text file that was last opened (well, this is vastly simplified, but this is the main gist).
To save the package, I've overridden NSDocument's -saveDocument:. It doesn't call super's method at all - all it does is write any text files that have been marked as changed into the project package as RTFD files and saves the project dictionary file.
In the past month, I've had two different users report a data loss issue to me. In both cases, it seems that their computer has gone into a deep sleep with my app open. Upon coming out of sleep - I'm not sure at which point here as the users have been vague, but I would imagine after they have closed and reopened the project - everything inside the package has been wiped except for the RTFD file that corresponds with the text document that is open in the text view. I'm not sure if the deep sleep has anything to do with it or is just a coincidence.
I should add that my app auto-saves on a delayed timer, so that -saveDocument: gets called after a few seconds of inactivity (any key-press or mouse movement delays the save until two seconds of inactivity have passed), but I don't think that has any effect here.
I've checked all my calls to NSFileManager's -removeFileAtPath:handler: and various calls to -writeToFile:... to see if anything could be accidentally replacing the project directory and there is nothing in my code that could be explicitly wiping these files; in the affected projects, there are files that get wiped that are never even touched after the initial project creation (for instance, the file version info file).
Is there anything in the system that I have described that would be leaving my app open to such data loss? The app has thousands of users and this has only ever been reported by two or three users, but when it comes to data loss I don't want to assume that it is just a fault with their machines or something odd that they have done. Both recent users have swore that they have done nothing odd to the file - they haven't moved it, synchronised it or anything else.
If anyone has any ideas about what might cause this sort of thing, I'd be very grateful to hear them. I know the above isn't much to go on, but there really is nothing else at play in my app that could wipe data.
Many thanks in advance and all the best,
Keith
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
_______________________________________________
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