AIR Deleted My Desktop!!

John C. Bland II

Ok…this isn’t a “spoof” post or anything like that. AIR literally deleted everything on my desktop as well as screwed something up on my OS (Vista). How did this happen? I’m glad you asked.

First off…I didn’t tell it to delete ANYTHING. I’m adding features to an app and one of the features is to save a file to a network share so I was testing it against my desktop directory. Since this is AIR I figured a simple file copy was sufficient.

Do you remember that old joke where someone sent you a spam email and opening the attachment showed your My Computer window deleting every file on your system? That’s how I felt watching my desktop directory contents leave.

I’m on Windows…just right click on Recyle Bin and restore, right? NOPE. AIR DELETED ALL OF MY FILES PERMANENTLY!!!!! Every file…gone. I open Computer and and it tells me “C:\Users\John C. Bland II\Desktop refers to a location that is unavailable. …” which is great because now I literally do not have a desktop (beyond a background image).

So, again…how did this happen? Ok…don’t get testy. I had to vent through sidebars real quick.

//Copy JSON file to web server
var file:File = File.createTempFile();
var stream:FileStream = new FileStream();
stream.open(file, FileMode.WRITE);
stream.writeUTF(“some content”);
stream.close();

var jsonFile:File = new File(_filePath);
jsonFile.resolvePath(“live” + _Index + “.json”);
file.copyTo(jsonFile, true);

So, this all works up to the last line. Odd right? I don’t have any delete lines. _copyTo(…)_ is the culprit. Yep, copy really should be: copyAndDeleteAllContentsInTheDirectoryThenMoveFile(….). :-(

What’s worse is the desktop directory is gone so I have NO idea if it even worked. Now I have to try it again. :-( This time I’m setting _filePath to _File.desktopDirectory.nativePath+”/myapp”_ so it will only delete that directory vs everything.

copyTo(…)’s overwrite explanation:
“If false, the copy will fail if the file specified by the target parameter already exists. If true, the operation will first delete any existing file or directory of the same name (however, you cannot copy a file or folder to its original path). (Note: If you set this parameter to true and the source and destination File objects point to the same path, calling this method deletes the file or directory.) ”

So…whatever it was…AIR DELETED MY DESKTOP! :-( Boo FLIPPIN’ hoo! :-(

UPDATE:
The bug is in my _resolvePath_. It should be _jsonFile = jsonFile.resolvePath(“live” + _Index + “.json”);_. So, AIR tried to copy a file to a directory which caused the directory to get nixed since it was an overwrite. The time you want Vista’s UAC to kick in…it is MIA! :-)




This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

6 Responses to “AIR Deleted My Desktop!!”

  • eric dolecki Says:

    Sorry man, that’s nasty!

    If it’s any consolation, I had Eclipse delete permanently my Desktop when I tried to create an Eclipse workspace there.

  • Scott D Says:

    I had a similar thing happen when using Eclipse for a very similar reason. I finally figured out what was going on, and it still boggles me why this type of command doesn’t copy first, THEN delete or clean up the source location.

  • John C. Bland II Says:

    Ewww….honestly…that softened the blow slightly. :-)

  • Billigflüge USA Says:

    Uh, that´s really anoying, but sorry man, it sounds funny as well:D I hope you haven´t had any important files on your desktop. So once again we´ve learned something about the importance of backups?^^

  • John C. Bland II Says:

    Nah, it wasn’t that big of a deal. It was more-so irritating that I wrote the code that did it. :-)

  • john Says:

    I installed the trial version of Flex. I created a test application on the desktop.
    When I deleted the application, from Flex, it deleted every file on my desktop.
    Could not believe it. Only a few could be salvaged from the recycle bin.

Leave a Reply

  • Advertisements

  • RSS John And Season

  • Get Adobe Flash playerPlugin by wpburn.com wordpress themes