mxcl/homebrew — pull request #21750 by samueljohn (2013-08-08 09:42:11+00:00)
Title: .DS_Store files should always be removed.

They get created when browsing homebrew dirs with the Finder and
we already treat a directory as "empty" if there is *only* one entry
and that entry is a `.DS_Store` file.

In therory this sounds good but in practice the way how Ruby's `find`
walks a file hierarchy is such that a dir is only visited once
and when there are more files on the first visit, the `.DS_Store` is
not removed and the dir is not re-visited later on when the other files
were unlinked. So we end up with an dir containing only a `.DS_Store` -
exactly what our code wanted to get rid of.

The symptom is that sometimes `brew ls` still lists a formula even if
it is actually not linked anymore. A second call to
`brew unlink ` then removes the `.DS_Store` because the dir
has only one entry then.

In fact, we can remove the `children.length == 1` check completely
and just delete (unlink) a `.DS_Store` file if `rmdir` raises the
`Errno::ENOTEMPTY` and retry the `rmdir`.

I am not aware of any software that uses `.DS_Store` files/features in
a shared dir like `etc` or `share`, so I think it is safe to get rid
of thoes files at this point.