revDeleteFolder and Lessons Learned..

Chipp Walters chipp at chipp.com
Thu Jul 7 22:42:51 EDT 2005


Here's an interesting story:

Last night I was working on a 'reset prefs' handler which was to remove 
all the files in a folder.

It looked something like:

on resetPrefs
   put lMasterFolderPath & "/" & lProjectName into tFolderToDelete
   revDeleteFolder tFolderToDelete
end resetPrefs

lMasterFolderPath and lProjectNames are script locals.

I also have a handler 'checkLocals' which I should've put at the top, 
but I digress.

In anycase, after applying the script and running, of course the script 
locals are now nulls and the revDeleteFolder contained only a single 
"/", which apparently means: "Delete the entire route hard drive".

After running it and seeing the processor shoot to 100% and stay there, 
I guessed something was wrong. I tried to quit it, but it's a shell 
script and even the task manager wouldn't allow me to kill it.

By the time I was able to force shutdown my machine, most the entire 
Windows partition was wasted. Fortunately, my Linux partition was still 
good and I could access my Documents folder and grab most of the stuff 
that mattered, but of course WinXP was completely hosed.

My lesson learned is NEVER, NEVER, NEVER use revDeleteFolder. I rewrote 
the script to use 'the files' and delete each file individually.

Hope others can learn from my mistake!

best,

Chipp



More information about the use-livecode mailing list