diff --git a/Library/Homebrew/cask/lib/hbc/artifact/moved.rb b/Library/Homebrew/cask/lib/hbc/artifact/moved.rb index a2f890e4ce..dacbe20b73 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/moved.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/moved.rb @@ -25,7 +25,7 @@ module Hbc private - def move(source, target, force: false, command: nil, **options) + def move(source, target, skip: false, force: false, command: nil, **options) if Utils.path_occupied?(target) message = "It seems there is already #{self.class.english_article} #{self.class.english_name} at '#{target}'" raise CaskError, "#{message}." unless force @@ -34,6 +34,8 @@ module Hbc end unless source.exist? + return if skip + raise CaskError, "It seems the #{self.class.english_name} source '#{source}' is not there." end diff --git a/Library/Homebrew/cask/lib/hbc/installer.rb b/Library/Homebrew/cask/lib/hbc/installer.rb index 88b77c62c7..03f2c6570b 100644 --- a/Library/Homebrew/cask/lib/hbc/installer.rb +++ b/Library/Homebrew/cask/lib/hbc/installer.rb @@ -368,7 +368,7 @@ module Hbc def uninstall oh1 "Uninstalling Cask #{@cask}" disable_accessibility_access - uninstall_artifacts + uninstall_artifacts(clear: true) purge_versioned_files purge_caskroom_path if force? end @@ -390,10 +390,10 @@ module Hbc def finalize_upgrade return unless upgrade? - purge_versioned_files(upgrade: true) + purge_versioned_files end - def uninstall_artifacts + def uninstall_artifacts(clear: false) odebug "Un-installing artifacts" artifacts = @cask.artifacts @@ -402,7 +402,7 @@ module Hbc artifacts.each do |artifact| next unless artifact.respond_to?(:uninstall_phase) odebug "Un-installing artifact of class #{artifact.class}" - artifact.uninstall_phase(command: @command, verbose: verbose?, force: force?) + artifact.uninstall_phase(command: @command, verbose: verbose?, skip: clear, force: force?) end end @@ -425,8 +425,8 @@ module Hbc Utils.gain_permissions_remove(path, command: @command) end - def purge_versioned_files(upgrade: false) - odebug "Purging files for version #{@cask.version} of Cask #{@cask}" unless upgrade? + def purge_versioned_files + ohai "Purging files for version #{@cask.version} of Cask #{@cask}" # versioned staged distribution gain_permissions_remove(@cask.staged_path) if !@cask.staged_path.nil? && @cask.staged_path.exist? diff --git a/Library/Homebrew/test/cask/cli/reinstall_spec.rb b/Library/Homebrew/test/cask/cli/reinstall_spec.rb index 5e551e5b5a..1df8147159 100644 --- a/Library/Homebrew/test/cask/cli/reinstall_spec.rb +++ b/Library/Homebrew/test/cask/cli/reinstall_spec.rb @@ -13,7 +13,8 @@ describe Hbc::CLI::Reinstall, :cask do Already downloaded: .*local-caffeine--1.2.3.zip ==> Verifying checksum for Cask local-caffeine ==> Uninstalling Cask local-caffeine - ==> Removing App '.*Caffeine.app'. + ==> Moving App 'Caffeine.app' to '.*Caffeine.app'. + ==> Purging files for version 1.2.3 of Cask local-caffeine ==> Installing Cask local-caffeine ==> Moving App 'Caffeine.app' to '.*Caffeine.app'. .*local-caffeine was successfully installed! diff --git a/Library/Homebrew/test/cask/cli/uninstall_spec.rb b/Library/Homebrew/test/cask/cli/uninstall_spec.rb index 1ab8f7e4da..578c0d43a7 100644 --- a/Library/Homebrew/test/cask/cli/uninstall_spec.rb +++ b/Library/Homebrew/test/cask/cli/uninstall_spec.rb @@ -12,7 +12,8 @@ describe Hbc::CLI::Uninstall, :cask do output = Regexp.new <<~EOS ==> Uninstalling Cask local-caffeine - ==> Removing App '.*Caffeine.app'. + ==> Moving App 'Caffeine.app' to '.*Caffeine.app'. + ==> Purging files for version 1.2.3 of Cask local-caffeine EOS expect {