I have occasionally encountered unexpected problems deleting directory trees (using rm -rf in a shell script). Recently, I encountered a similar problem using a third party application that failed to delete a directory tree using Java APIs. In both situations, the problem turned out to be a failure to remove a directory because it was not empty, and the file it contained was a .DS_Store file. This is odd for two reasons:
- The directory was not one I had viewed using Finder, so why was a .DS_Store file created?
- The .DS_store file was not protected, so why wasn't it deleted along with the other files in the directory?
The only explanation I can think of is that the .DS_Store file was created by a background thread, which is possible, but what would a background thread be doing that would cause a .DS_Store file to be created?