diff options
| author | Xu Cheng | 2015-08-17 22:56:00 +0800 |
|---|---|---|
| committer | Xu Cheng | 2015-08-18 15:58:07 +0800 |
| commit | 4740d7fad4663af07bc06693ae481294632ea9b1 (patch) | |
| tree | d4ea48a3c3853acfd78c4ac6c4609a5f1370a55c | |
| parent | 4d84ff3b03b6d0f76cc249ebe9cf8ce9722dc09a (diff) | |
| download | brew-4740d7fad4663af07bc06693ae481294632ea9b1.tar.bz2 | |
uninstall: simplify logic
Also reduce unnecessary disk operations
Closes Homebrew/homebrew#43024.
Signed-off-by: Xu Cheng <xucheng@me.com>
| -rw-r--r-- | Library/Homebrew/cmd/uninstall.rb | 27 |
1 files changed, 6 insertions, 21 deletions
diff --git a/Library/Homebrew/cmd/uninstall.rb b/Library/Homebrew/cmd/uninstall.rb index 8a5c4baba..0dbdc08c4 100644 --- a/Library/Homebrew/cmd/uninstall.rb +++ b/Library/Homebrew/cmd/uninstall.rb @@ -6,23 +6,10 @@ module Homebrew def uninstall raise KegUnspecifiedError if ARGV.named.empty? - # Find symlinks that can point to keg.rack - links = HOMEBREW_CELLAR.subdirs.select(&:symlink?) - if !ARGV.force? ARGV.kegs.each do |keg| keg.lock do puts "Uninstalling #{keg}... (#{keg.abv})" - - old_cellars = [] - # Remove every symlink that links to keg, because it can - # be left by migrator - links.each do |link| - if link.exist? && link.realpath == keg.rack.realpath - old_cellars << link - end - end - keg.unlink keg.uninstall rack = keg.rack @@ -33,10 +20,6 @@ module Homebrew verb = versions.length == 1 ? "is" : "are" puts "#{keg.name} #{versions.join(", ")} #{verb} still installed." puts "Remove them all with `brew uninstall --force #{keg.name}`." - else - # If we delete Cellar/newname, then Cellar/oldname symlink - # can become broken and we have to remove it. - old_cellars.each(&:unlink) end end end @@ -45,10 +28,6 @@ module Homebrew rack = Formulary.to_rack(name) name = rack.basename - links.each do |link| - link.unlink if link.exist? && link.realpath == rack.realpath - end - if rack.directory? puts "Uninstalling #{name}... (#{rack.abv})" rack.subdirs.each do |d| @@ -64,6 +43,12 @@ module Homebrew rescue MultipleVersionsInstalledError => e ofail e puts "Use `brew uninstall --force #{e.name}` to remove all versions." + ensure + # If we delete Cellar/newname, then Cellar/oldname symlink + # can become broken and we have to remove it. + HOMEBREW_CELLAR.children.each do |rack| + rack.unlink if rack.symlink? && !rack.resolved_path_exists? + end end def rm_pin(rack) |
