Fail if cask source already exists.

This commit is contained in:
Markus Reiter 2016-11-28 13:38:49 +01:00
parent 3bcf80f651
commit 9a29bd35e6
3 changed files with 4 additions and 3 deletions

View File

@ -45,8 +45,7 @@ module Hbc
if force if force
ohai(warning_target_exists { |s| s << "overwriting." }) ohai(warning_target_exists { |s| s << "overwriting." })
else else
ohai(warning_target_exists { |s| s << "not moving." }) raise CaskError, warning_target_exists << "."
return false
end end
end end
unless source.exist? unless source.exist?

View File

@ -39,7 +39,7 @@ module Hbc
def preflight_checks(source, target) def preflight_checks(source, target)
if target.exist? && !self.class.islink?(target) if target.exist? && !self.class.islink?(target)
ohai "It seems there is already #{self.class.artifact_english_article} #{self.class.artifact_english_name} at '#{target}'; not linking." opoo "It seems there is already #{self.class.artifact_english_article} #{self.class.artifact_english_name} at '#{target}'; not linking."
return false return false
end end
unless source.exist? unless source.exist?

View File

@ -35,6 +35,8 @@ module Hbc
rescue CaskNoShasumError => e rescue CaskNoShasumError => e
opoo e.message opoo e.message
count += 1 count += 1
rescue CaskError => e
onoe e.message
end end
end end
count.zero? ? nil : count == cask_tokens.length count.zero? ? nil : count == cask_tokens.length