Wednesday, June 13, 2007

Foolishness and recovery

(Warning: Some background knowledge about the working of CVS is needed to understand this paragraph.) One of the few ways to kick yourself in the foot with CVS is to create a new file (in this case, a .java); forget to add it to the CVS; commit the other files; and then try to test if the build works by deleting the whole folder and checking out again there.

Short story short, three hours of hard (copy-paste) work was going to go down the drain. The file had gone; I had to recover it.

Google. The first result was this supposedly oft-used program called DiskInternals Uneraser available from http://www.diskinternals.com/. The program took quite some time to scan the partition and then did find the deleted .java and .class file, but said it needed the paid version (~10$) to actually recover them. Searching for a crack (using a GNU/Linux box, of course) was in vain. Some site actually made me download a .zip and then had a file in it which read:
S/N: Evalution

I searched some more and found:
http://www.ntfsundelete.com/
A nice piece of gratis software from a company known as Atola Technologies, this product did the job well. It scanned through the disk faster, had a better interface than the DiskInternals Uneraser, and managed to try to recover the files without any payment of any sort. It turned out that the .java file couldn't be recovered fully, but the .class file could. But I did need the source. Then comes another gratis software cavaj (downloadable from http://www.bysoft.se/sureshot/cavaj/) to the rescue. Cavaj gracefully created the .java from the class file, and this .java was almost compilable. Just a one line change, and I had my file back!

2 comments:

ksp said...

Lucky!

However I couldn't resist:

bzr commit --strict

will refuse to commit if there are unknown files in the directory. I couldn't find a cvs equivalent.

bzr status

will tell you what is the status of the repository, as in what files have been modified, added, deleted, etc.

And of course, bzr works on Windows. Maybe it's time to save yourself some CVS pain? Indeed, why not switch to svn?
It has status, but commit --strict seems to be an arch thing.

But bzr doesn't make you immune either -- I once deleted the whole directory, since I come from an arch background without realising that there is no *working* directory in bzr -- the current directory is the repo. They're there in baz and arch/tla. Thankfully I'd branched my repo, and restoring was easy, since every branch is independent :)

Didn't get the NTFS on GNU/Linux thing, though

Devadutta Ghat said...

does de-compiling a .java file regain the original variable names?
I know C#.NET stores metadata which can be used for such a feature, but does this java decompiler do the same?