Remove .DS_Store files when uninstalling packages

.DS_Store files (http://en.wikipedia.org/wiki/.DS_Store) may litter
directories installed with pkgutil preventing them testing as empty and
getting deleted. Delete them along with symlinks.
This commit is contained in:
Benjamin Hawkes-Lewis 2013-09-23 11:46:41 +01:00
parent d180bf494a
commit ec18210887
1 changed files with 8 additions and 0 deletions

View File

@ -19,6 +19,7 @@ class Cask::Pkg
_deepest_path_first(dirs).each do |dir| _deepest_path_first(dirs).each do |dir|
@command.run('chmod', :args => ['777', dir], :sudo => true) @command.run('chmod', :args => ['777', dir], :sudo => true)
_clean_symlinks(dir) _clean_symlinks(dir)
_clean_ds_store(dir)
@command.run('rmdir', :args => [dir], :sudo => true) if dir.exist? && dir.children.empty? @command.run('rmdir', :args => [dir], :sudo => true) if dir.exist? && dir.children.empty?
end end
forget forget
@ -66,4 +67,11 @@ class Cask::Pkg
@command.run('rm', :args => [child], :sudo => true) if child.symlink? @command.run('rm', :args => [child], :sudo => true) if child.symlink?
end end
end end
def _clean_ds_store(dir)
# Clean .DS_Store files:
# https://en.wikipedia.org/wiki/.DS_Store
ds_store = dir.join('.DS_Store')
@command.run('rm', :args => [ds_store], :sudo => true) if ds_store.exist?
end
end end