AIR Deleted My Desktop!!

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! :-)

  • http://www.ericd.net eric dolecki

    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.

  • http://www.flatoutmedia.com Scott D

    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

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

  • http://www.ticketpoint.de/billigfluege/billigfluege-nordamerika/billigfluege-usa.html Billigflüge USA

    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

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

  • john

    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.

  • JUNIOR

    IDIOT FLEX.

    You might blame I'm new but it isn't user's friendly at all.

    See, I create a new project on desktop, with a folder to store everything.

    Then while deleting the folder and the content, everything in desktop gone. I can't even recover it from recycle bin. Anyone work with dreamweaver before would know this certainly isn't the way.

    STUPID FLEX where it expect everyone is the master of flex.

    I rather hope it's a bug.

    While searching through net, so many caught with the same problem.

    Yes to those dude talking about backup and restore, downloading the undelete program – it is the after math solution…..but on the first place, this shouldn't be how a program works. Adobe seem don't bother. I too saw in the net AIR did the same stupid work.

    ADOBE PLEASE DON'T MAKE PPL SUFFER BECAUSE OF THE UNFRIENDLY FEATURES.

    • http://intensedebate.com/people/johncblandii johncblandii

      Junior, if you pointed Flex Builder (or Flash Builder) to your desktop as the project location (which would have created bin-debug, html-template, etc folders on your desktop), then deleted it…that's a user error. ;-)

      *Builder deletes the contents of the containing folder so dumping it all on your desktop means it would delete your desktop folder contents. That's a bad practice and I never suggest doing that at all. Too bad it happened though…sucks big time when it does.

  • Luke

    Just happened to me, and my magnificent desktop which just happened to be storing something I just started working on… downloaded flash for another computer, told it to download to my desktop, poof, everything gone, thank you for using adobe delete manager, and thank you for being stupid and thinking that adobe knows how to make something useful…

    • http://www.johncblandii.com johncblandii

      Lol. My issue was actually caused by my bad code though. :) Yours is weird for sure and sucks bad. Hope you have a way to recover.