Revert install_artifacts if one artifact fails to install.
This commit is contained in:
parent
e6d9248787
commit
5785f54f4b
@ -132,14 +132,29 @@ module Hbc
|
|||||||
end
|
end
|
||||||
|
|
||||||
def install_artifacts
|
def install_artifacts
|
||||||
|
already_installed_artifacts = []
|
||||||
|
options = { command: @command, force: force }
|
||||||
|
|
||||||
odebug "Installing artifacts"
|
odebug "Installing artifacts"
|
||||||
artifacts = Artifact.for_cask(@cask)
|
artifacts = Artifact.for_cask(@cask)
|
||||||
odebug "#{artifacts.length} artifact/s defined", artifacts
|
odebug "#{artifacts.length} artifact/s defined", artifacts
|
||||||
|
|
||||||
artifacts.each do |artifact|
|
artifacts.each do |artifact|
|
||||||
odebug "Installing artifact of class #{artifact}"
|
odebug "Installing artifact of class #{artifact}"
|
||||||
options = { command: @command, force: force }
|
already_installed_artifacts.unshift(artifact)
|
||||||
artifact.new(@cask, options).install_phase
|
artifact.new(@cask, options).install_phase
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
# TODO: move dependencies to a separate class
|
# TODO: move dependencies to a separate class
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user