Consultant Scott Rose has isolated a potentially dangerous problem in Mac OS X 10.5 Leopard that could cause data loss for people who rely on the Dock or the Apple menu's Recent Items submenu as a launcher for in-progress documents. The steps to reproduce the problem aren't likely to bite careful users, but it's easy enough to see someone accidentally stumbling into the situation, as did one of Scott's clients.
The Problem -- Assume you drag frequently used documents to the Dock for quick access, and once in the Dock, you use those Dock aliases exclusively for opening documents. Or, imagine that you use the Apple menu's Recent Items submenu or applications' Open Recent submenus to access your in-progress documents. Further assume that for some reason, perhaps accidentally, you move one of these important files to the Trash.
Normally, if you double-click a file in the Trash, the Finder refuses to open it, telling you to remove it from the Trash first. The warning makes perfect sense, since it would be all too easy to empty the Trash while working and lose your file.
However, if you open a trashed document via the Dock, the Recent Items submenu, or an application's Open Recent submenu, some applications allow you to open the document, make changes, and save your changes, all without the slightest warning. Were you to empty the Trash, your data would be lost, and you'd be left with no recourse short of a therapeutic bout of cursing. (And yes, this would definitely fall into the category of "user error," but if Apple is going to prevent people from double-clicking files in the Trash, the least they can do is be consistent about other ways of opening files in the Trash.)
In a quick spot check of applications I use, programs that allowed editing of files in the Trash include Microsoft Word 2004 (but not 2008), Microsoft Excel 2008, and BBEdit 9.1.1. Scott Rose also tells me that he's verified the problem in FileMaker Pro (any version), Quicken 2007, and Final Draft 7.
On the other side of the spectrum, Apple's own TextEdit, Preview, Pages '09, and Numbers '09 alert you that the file is stored in the Trash and require you to save it elsewhere. Microsoft Word 2008 presents a clear dialog telling you to move the document out of the Trash or use Save As. Adobe Photoshop CS3 lets you open the file and make changes, but when you try to save, it forces a Save As without any explanation. On my first test with Adobe InDesign CS3, it crashed; subsequent tests merely closed the document without warning or explanation as soon as I opened it.
Testing would be required to determine how any given program will react to this situation, so if you rely on the Dock, Recent Items, or Open Recent as a launcher for in-progress documents, you may wish to check the applications you use. I haven't tested Mac OS X 10.4 Tiger with regard to opening trashed documents, but I'd guess that the problem exists in that version as well.
Exacerbating the problem is the fact that Leopard's Time Machine doesn't back up files once they're in the Trash. It may have a backup of the file before it was moved to the Trash, but that could be significantly out of date, were you to empty the Trash and then look to Time Machine to restore the most recent backup.
Who's Responsible? From the varying results in my testing, it's clear that responsibility currently lies with application developers to notice that an open file is located in the Trash and to prompt the user appropriately. Apple's own programs appear to do that, and I strongly encourage developers to perform that check on either open or save, preferably open.
More generally, though, and the reason I think Apple should modify Mac OS X to eliminate this possibility of data loss, is that the Finder and the Dock behave differently in exactly the same situation, and the Finder itself displays inconsistent behavior. Double-click a file in the Trash, and the Finder forces you to move it before opening it. The Finder also warns you appropriately if you put a document in the sidebar or toolbar, trash the file, and then try to open it. But open a trashed file by clicking it in the Dock or from the Recent Items submenu, and... it just works (which is a bad thing, in this case).
For the sake of both consistency and safety, the Dock, the Recent Items submenu, and the Open Recent submenu in applications should refuse to open any file that's stored in the Trash. And, ideally, the Finder should offer to move the offending file to the user's Desktop, rather than just presenting an error dialog. That would just be polite.
Plus, although fixing this bug would address the issue of opening files in the Trash, I believe that Time Machine should back up the contents of the Trash, just like everything else, since it's all too easy to create a file and trash it within the hour-long time frame that Time Machine operates, thus preventing Time Machine from ever seeing that file.
I've reported this problem to Apple, and with luck, it will be addressed in Snow Leopard.
[Thanks to reader Matt Strange for suggesting that I investigate the behavior of Recent Items and Open Recent as well. Based on those results, I recast the article so it doesn't focus so much on the Dock, since the problem obviously exists in other areas of Mac OS X as well. -Adam]