Apple’s TextEdit application has a massive design flaw that could potentially erase other files on your computer. Weird, right? Ironically, it’s TextEdit’s safeguard against loss of data that is the culprit of the defect. And the corruption of files isn’t a randomly occurring glitch either — it is caused by a shortcoming of the algorithm used in the Autosave feature.
The Autosave Flaw
When editing a document in TextEdit, a copy of your work is automatically saved every 30 seconds to the hard drive*. This behavior is common in software as it provides a convenient means to recover some of your work should the application unexpectedly quit or crash.
Unfortunately, the means by which TextEdit saves a copy of your work is awfully rudimentary. It simply writes your data to a regular file and gives it the same name as your TextEdit document but with “ (Autosaved)” appended as a suffix (without an extension). And since no verification is performed to see if a file with that particular name already exists, it will overwrite anything that gets in its way with no confirmation or warning!
Example
To better illustrate this flaw, take the following scenario. Suppose, for whatever reason, that I have a file named Craziness (Autosaved) and I create a text document called Craziness.txt in the same directory. In the screenshot below Craziness (Autosaved) is an image file (with the extension removed in order to illustrate my point):

When I start editing my Craziness.txt file in TextEdit, the application autosaves my work (as it should), but since my image document has the same name as what TextEdit would call its autosaved file, my image file is overwritten:

When I’m done editing my Craziness.txt document, TextEdit removes the autosaved copy (as one would expect). However, now my original image file is gone with no real way to recover it (since it’s not moved to the Trash but actually overwritten):

Solutions
Accounting for this file naming issue is so programmatically simple that it’s astounding the defect even exists. The simplest improvement would be to prefix the filename with a period (as in .Craziness (Autosaved)) in order to hide it from the Finder since the chances of having a naming conflict with a hidden file are greatly reduced.
But hiding the file from the user still allows for potential name collisions and as Mac OS X’s default text editor, TextEdit’s naming convention should be even more robust. To start, TextEdit could include either a timestamp or a sequence of random numbers to help make its autosaved filename unique. Most importantly, however, should be to verify if a file would be overwritten and if so, generate a different random number or append an incremental counter. Heck, even my Page Capture widget won’t overwrite files since it uses the same naming convention as Apple’s screencapturing application (File 1, File 2, File 3, etc.)
The Rant
One might argue that the possibility of having a file end with “ (Autosaved)” and not have an extension is pretty slim. So what? My argument is that the possibility of an application deleting other files blindly is a completely unacceptable use case scenario, no matter how rarely it may occur. I think it is more reasonable to expect that a corporation as large as Apple Inc. would produce software that doesn’t delete unrelated files from my hard drive without my knowledge. Especially since OS X is — as Apple claims — the “most advanced operating system in the world.”
*30 seconds is the default. The time interval is configurable and the user is allowed to disable the Autosave feature entirely.
May 12th, 2009 by Paulo
(32 Comments »)
Good brief and this enter helped me alot in my college assignement. Say thank you you seeking your information.
You have really great taste on catch article titles, even when you are not interested in this topic you push to read it
…
Yes! I agree what you say. Here you can always look the best White Gold Wedding Bands!…
…
I admire the useful facts you offer inside your articles. I will bookmark your blog site and have my children check up here generally. I’m pretty certain they’ll understand plenty of new stuff here than anybody else!…
…
Yes, thank for your data a million! Ought to find anybody organizing Tea Party. I wants to participate in organizing….
…
How’s it intending? I loved reading through this submit. My husband and I have been searching for this sort of article for the longest time and We know that your info within the difficulty at hand is spot on. I will be positive to introduce this post t…
Another Title…
I saw this really great post today….
…
Fantastic blog site, thanks a great deal for your awesome posts!…
…
Cheers for the information. Significantly appreciated….
…
Hi there may I reference some from the insight right here in this website if I reference you with a link back for your web page?…
Another Title…
I saw this really good post today….
…
Cheers for your facts. Significantly appreciated….
…
You guys possess a excellent website proceeding below, KIU!…
…
Incredibly frequently I go to this web site. It incredibly much is pleasant to me. Many thanks the author!…
…
Me and my friend were arguing about an matter similar to this! Now I realize that I was correct. lol! Thanks for the information you publish….
…
Sweet submit….
…
Your point is valueble for me. Thanks!…
About the wonderful, very pleased to see this article, learn some things, and view the text is recognized. Thank you for sharing. At the same time,i love Buy Baby stroller very much !
Bar & Business For Sale…
thanks for this…
…
Primary factor , A big thanks to you to open my eyes….
…
I admire the valuable info you offer you in your articles. I will bookmark your website and have my children check up here frequently. I am very sure they will find out plenty of new things the following than anybody else!…
…
Hi, thank you so a lot for these tips!…
…
This publish may be pointed out on Twitter by someone. actually?…
…
Hi! Your publish rocks and is usually a very good understand!…
Purchase mp3 music online…
Thanks for good information that comes out to read….
…
This is a good website article and I defer to you what you might have mentioned right here. I have currently subscribed for a RSS feed in Firefox and will likely be your normal reader. Many thanks for your time in writing the write-up….
…
Cheers for this article, guys, keep up the excellent work….
…
Thank you for your well-thought post. I’m really at perform right now! So I have to go off without examining all I’d like. But, I set your website on my RSS feed in order that I can examine far more….
…
Many thanks for that well-thought content. I’m really at operate right now! So I should go off with out reading all I’d like. But, I set your web site on my RSS feed in order that I can understand much more….
…
Many thanks for your excellent submit. I’ll take the notes you’ve written….
…
This is a very good blog site article and I defer for you what you have mentioned below. I’ve previously subscribed on your RSS feed in Firefox and will probably be your regular reader. Many thanks for your time in writing the submit….
…
I would like to thank you to the endeavors you could have made in publishing this write-up. I am trusting the exact same best work from you in the long term too. Actually your fanciful writing abilities has inspired me to start my very own blog site no…