From 16723afaa8df464aad242e11a0b69ab7f7a5c1bf Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Sat, 27 Apr 2013 15:21:05 -0500 Subject: [PATCH] Only remove DS_Store on ENOTEMPTY --- Library/Homebrew/extend/pathname.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb index df8f3813eb..ef7dcea993 100644 --- a/Library/Homebrew/extend/pathname.rb +++ b/Library/Homebrew/extend/pathname.rb @@ -141,14 +141,14 @@ class Pathname def rmdir_if_possible rmdir true - rescue SystemCallError => e - # OK, maybe there was only a single `.DS_Store` file in that folder - if (self/'.DS_Store').exist? && self.children.length == 1 - (self/'.DS_Store').unlink + rescue Errno::ENOTEMPTY + if (ds_store = self+'.DS_Store').exist? && children.length == 1 + ds_store.unlink retry + else + false end - - raise unless e.errno == Errno::ENOTEMPTY::Errno or e.errno == Errno::EACCES::Errno or e.errno == Errno::ENOENT::Errno + rescue Errno::EACCES, Errno::ENOENT false end