Rework uninstallation step

Now the artifacts get re-staged, and upon an uninstall/finalize_upgrade
they are deleted by purge_versioned_files instead
This commit is contained in:
L. E. Segovia 2017-11-06 21:27:02 -03:00
parent 84c128411f
commit 94d266e2d6
2 changed files with 9 additions and 9 deletions

View File

@ -8,11 +8,11 @@ module Hbc
end
def install_phase(**options)
move(**options)
move(source, target, **options)
end
def uninstall_phase(**options)
delete(**options)
move(target, source, **options)
end
def summarize_installed
@ -25,12 +25,12 @@ module Hbc
private
def move(force: false, command: nil, **options)
def move(source, target, 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
opoo "#{message}; overwriting."
delete(force: force, command: command, **options)
delete(target, force: force, command: command, **options)
end
unless source.exist?
@ -49,7 +49,7 @@ module Hbc
add_altname_metadata(target, source.basename, command: command)
end
def delete(force: false, command: nil, **_)
def delete(target, force: false, command: nil, **_)
ohai "Removing #{self.class.english_name} '#{target}'."
raise CaskError, "Cannot remove undeletable #{self.class.english_name}." if MacOS.undeletable?(target)

View File

@ -136,7 +136,7 @@ module Hbc
def summary
s = ""
s << "#{Emoji.install_badge} " if Emoji.enabled?
s << "#{@cask} was successfully installed!"
s << "#{@cask} was successfully #{upgrade? ? "upgraded" : "installed"}!"
end
def download
@ -384,13 +384,13 @@ module Hbc
def revert_upgrade
return unless upgrade?
opoo "Reverting upgrade for Cask #{@cask}"
reinstall
install_artifacts
enable_accessibility_access
end
def finalize_upgrade
return unless upgrade?
purge_versioned_files(upgrade: true)
oh1 "Cask #{@cask} was successfully upgraded!"
end
def uninstall_artifacts
@ -426,7 +426,7 @@ module Hbc
end
def purge_versioned_files(upgrade: false)
odebug "Purging files for version #{@cask.version} of Cask #{@cask}"
ohai "Purging files for version #{@cask.version} of Cask #{@cask}" unless upgrade?
# versioned staged distribution
gain_permissions_remove(@cask.staged_path) if !@cask.staged_path.nil? && @cask.staged_path.exist?