aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cask/lib
diff options
context:
space:
mode:
authorL. E. Segovia2017-11-12 09:25:15 -0300
committerL. E. Segovia2017-11-13 08:46:08 -0300
commit36fe355159385669fbd5c294b901ed1df5bc745f (patch)
tree6aff81617274c53412e034dddf5e0b4227dcb51b /Library/Homebrew/cask/lib
parent8cc1aea5f07d1fdfb9cf8ae9a5687c571a856312 (diff)
downloadbrew-36fe355159385669fbd5c294b901ed1df5bc745f.tar.bz2
Add tests for upgrade recovery
Diffstat (limited to 'Library/Homebrew/cask/lib')
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/upgrade.rb11
1 files changed, 9 insertions, 2 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/cli/upgrade.rb b/Library/Homebrew/cask/lib/hbc/cli/upgrade.rb
index 90da6f325..94fe56a47 100644
--- a/Library/Homebrew/cask/lib/hbc/cli/upgrade.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli/upgrade.rb
@@ -41,6 +41,9 @@ module Hbc
require_sha: require_sha?,
upgrade: true)
+ started_upgrade = false
+ new_artifacts_installed = false
+
begin
# Start new Cask's installation steps
new_cask_installer.check_conflicts
@@ -51,9 +54,12 @@ module Hbc
# Move the old Cask's artifacts back to staging
old_cask_installer.start_upgrade
+ # And flag it so in case of error
+ started_upgrade = true
# Install the new Cask
new_cask_installer.install_artifacts
+ new_artifacts_installed = true
new_cask_installer.enable_accessibility_access
@@ -61,8 +67,9 @@ module Hbc
old_cask_installer.finalize_upgrade
rescue CaskError => e
opoo e.message
- new_cask_installer.uninstall
- old_cask_installer.revert_upgrade
+ new_cask_installer.uninstall_artifacts if new_artifacts_installed
+ new_cask_installer.purge_versioned_files
+ old_cask_installer.revert_upgrade if started_upgrade
end
end
end