I just experienced a nasty bug with Finder which results in data loss. Thankfully in this situation I had a copy of the original file, but it’s a very unpleasant bug.
- A customer sent me a zip file called var_adm_messages.zip
- I unzipped the file, which created the directory var_adm_messages, and in that directory it created the file messages
- I renamed the file in var_adm_messages from ‘messages’ to var_adm_messages
- I moved the var_adm_messages file up one level – i.e., into the parent directory that also contained the var_adm_messages directory
Here’s where it gets (a) dangerous and (b) interesting.
So, here’s what my folder structure looks like:
Having renamed the ‘messages’ file to ‘var_adm_messages’, I drag it out to the parent folder, and choose to Replace, since I won’t need the var_adm_messages folder any longer:
All good. Now, at this point I’d expect to see the ‘var_adm_messages’ folder disappear, and be replaced by the ‘var_adm_messages’ file. Instead:
Result? Both the file that I wanted, and the original directory, removed.
I suspect Finder is deleting the directory first, which consequently trashes the file that I wanted to move, and subsequently silently fails on the file move.
I know what I’m doing in this situation isn’t what someone would do on a daily basis, but it does violate the rule of least astonishment – and it does generate data loss.
All I can say is: Urgh.