Only remove DS_Store on ENOTEMPTY
This commit is contained in:
parent
bffe090b21
commit
16723afaa8
@ -141,14 +141,14 @@ class Pathname
|
|||||||
def rmdir_if_possible
|
def rmdir_if_possible
|
||||||
rmdir
|
rmdir
|
||||||
true
|
true
|
||||||
rescue SystemCallError => e
|
rescue Errno::ENOTEMPTY
|
||||||
# OK, maybe there was only a single `.DS_Store` file in that folder
|
if (ds_store = self+'.DS_Store').exist? && children.length == 1
|
||||||
if (self/'.DS_Store').exist? && self.children.length == 1
|
ds_store.unlink
|
||||||
(self/'.DS_Store').unlink
|
|
||||||
retry
|
retry
|
||||||
|
else
|
||||||
|
false
|
||||||
end
|
end
|
||||||
|
rescue Errno::EACCES, Errno::ENOENT
|
||||||
raise unless e.errno == Errno::ENOTEMPTY::Errno or e.errno == Errno::EACCES::Errno or e.errno == Errno::ENOENT::Errno
|
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user