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.

Scenario:

  • 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:

Finder bug 2

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:

Finder Bug 3

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.

Related posts:

  1. Zero schmero
  2. Annoying inconsistencies in interface design

  One Response to “Finder Bug with Folders”

  1. You’re right it’s a Finder bug, ’cause that’s just not possible under Unix. Simply can’t be done. Viz:

    /tmp>mkdir gam
    /tmp>touch gam/gam
    /tmp > mv gam/gam /tmp/gam
    mv: gam/gam and /tmp/gam/gam are identical

    Unix says: Hey, you’re trying to move the file gam in the directory gam *back into* the directory gam & guess what – it’s already there!

    The other way to look at what you’re doing is:

    /tmp > mv gam/gam /tmp/
    mv: rename gam/gam to /tmp/gam: Is a directory

    i.e. you can’t rename a file in a directory to a parent directory of the same name. File system won’t ‘ave it, it won’t.

    So yes – a nasty bug, but whichever way you look at this in the underlying Unix system – it ain’t gonna work. The Finder really should be preventing this type of thing, or, (if they decide to make it smart) doing this:

    /tmp > mv gam/gam gam/spam
    /tmp > mv gam/spam /tmp/
    /tmp> rmdir gam
    /tmp> mv spam gam

    Bit of a palarva, innit? Finder would have to rename the file to a temp name, move it up to the parent folder, remove the former parent directory, and finally, rename the file from the temporary name to the original. That’s the only way it would work. I wouldn’t hold my breath for that…

    Regards,

    GAM

 Leave a Reply

(required)

(required)


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

   
© 2012 unsane Suffusion theme by Sayontan Sinha