aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMarkus Reiter2016-12-04 23:14:35 +0100
committerMarkus Reiter2016-12-04 23:19:15 +0100
commit5785f54f4bd48dca58a7550af48217d4c6372ad2 (patch)
tree6fe7538d7dbf19030f33bb0cedd61021dc4e0a44 /Library
parente6d9248787b26008b86ecb4dfddba7fb15ba98a5 (diff)
downloadbrew-5785f54f4bd48dca58a7550af48217d4c6372ad2.tar.bz2
Revert `install_artifacts` if one artifact fails to install.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cask/lib/hbc/installer.rb17
1 files changed, 16 insertions, 1 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/installer.rb b/Library/Homebrew/cask/lib/hbc/installer.rb
index df7554cc5..5176143d7 100644
--- a/Library/Homebrew/cask/lib/hbc/installer.rb
+++ b/Library/Homebrew/cask/lib/hbc/installer.rb
@@ -132,14 +132,29 @@ module Hbc
end
def install_artifacts
+ already_installed_artifacts = []
+ options = { command: @command, force: force }
+
odebug "Installing artifacts"
artifacts = Artifact.for_cask(@cask)
odebug "#{artifacts.length} artifact/s defined", artifacts
+
artifacts.each do |artifact|
odebug "Installing artifact of class #{artifact}"
- options = { command: @command, force: force }
+ already_installed_artifacts.unshift(artifact)
artifact.new(@cask, options).install_phase
end
+ rescue StandardError => e
+ begin
+ ofail e.message
+ already_installed_artifacts.each do |artifact|
+ odebug "Reverting installation of artifact of class #{artifact}"
+ artifact.new(@cask, options).uninstall_phase
+ end
+ ensure
+ purge_versioned_files
+ raise e.class, "An error occured during installation of Cask #{@cask}: #{e.message}"
+ end
end
# TODO: move dependencies to a separate class