User forums > Help

My entire C file cleared and lost by CB

<< < (2/4) > >>

thomas:
I've looked at everything that opens, read, writes or otherwise touches files, found nothing that could possibly truncate or write a bunch of zeroes to a file under normal conditions (of course everything is possible in a crash...). :(

The algorithm used to save files is as this:
1. if file.c does not exist, write data directly to file, end of operation
2. write data to file.c.cbTemp
3. rename file.c to file.c.backup
4. rename file.c.cbTemp to file.c
5. delete file.c.backup

So, .cbTemp and .backup are the file types to look for, when doing recovery.

thomas:
Acutally the above is not 100% correct, since some wizards will indeed overwrite existing files without warning. But since you were not running a wizard, I guess that is not related.

MortenMacFly:

--- Quote from: thomas on August 28, 2007, 04:37:49 pm ---Acutally the above is not 100% correct, since some wizards will indeed overwrite existing files without warning.

--- End quote ---
:shock: Which one? Are there still wizards that do so? I thought we have fixed that finally?!

@nthony:
If step 4, renaming of file.c.cbTemp, is not succesful, what happens to .cbTemp? Is it deleted along with .backup, or left in place? Also, even more scary is the possibility that the writing operation did complete successfully, instead CB might have cleared the file through the editor. So in that situation, the file algorithm would have functioned properly, but whatever decided to clear the contents of the editor, then save it, and then crash on top of that, would be at fault. I don't believe any wizards and/or third-party plugins were running at the time.

thomas:

--- Quote ---:shock: Which one? Are there still wizards that do so? I thought we have fixed that finally?!

--- End quote ---
All wizards that generate content do. Wizards that copy files do not.

1. Make a folder, call it for example overwrite
2. Copy a file into this folder, for example foo.cpp  (make sure this is NOT a file you still need!)
3. Start the Plugin wizard, tell it that your project name is overwrite
4. Click OK until you get to name your plugin, name it foo
5. Click OK
6. Your file foo.cpp is gone.


--- Quote ---If step 4, renaming of file.c.cbTemp, is not succesful, what happens to .cbTemp?
--- End quote ---
If it is successful, a delayed delete is issued on the backup file. This is an extra security measure, deleting the file only after a grace period of 3 seconds. The reasoning behind this is that if you have a power failure at the precise moment of file renames and both the old and new versions are screwed up for some reason, the backup isn't deleted too. It is assumed that this "extra time" is good enough to give the hard disk time to physically lay down changes before anything is deleted.

If the rename fails, the backup file is renamed to the original file name (this is significantly different from the wx "safe write" implementation, which actually loses the data in this case).


--- Quote ---Also, even more scary is the possibility that the writing operation did complete successfully, instead CB might have cleared the file through the editor.
--- End quote ---
Hmm yes, if this happens (I don't see a reason why it should, but you never know... during a crash anything can happen) then obviously your data will be overwritten. But I see no way to prevent this, we have no way of telling.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version