From 9a29bd35e6d6e1a446c02b14d43b6dd52733821e Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Mon, 28 Nov 2016 13:38:49 +0100 Subject: [PATCH] Fail if cask source already exists. --- Library/Homebrew/cask/lib/hbc/artifact/moved.rb | 3 +-- Library/Homebrew/cask/lib/hbc/artifact/symlinked.rb | 2 +- Library/Homebrew/cask/lib/hbc/cli/install.rb | 2 ++ 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/cask/lib/hbc/artifact/moved.rb b/Library/Homebrew/cask/lib/hbc/artifact/moved.rb index f1e542e7a3..7322924e85 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/moved.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/moved.rb @@ -45,8 +45,7 @@ module Hbc if force ohai(warning_target_exists { |s| s << "overwriting." }) else - ohai(warning_target_exists { |s| s << "not moving." }) - return false + raise CaskError, warning_target_exists << "." end end unless source.exist? diff --git a/Library/Homebrew/cask/lib/hbc/artifact/symlinked.rb b/Library/Homebrew/cask/lib/hbc/artifact/symlinked.rb index 32d8d68405..69b388425e 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/symlinked.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/symlinked.rb @@ -39,7 +39,7 @@ module Hbc def preflight_checks(source, 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 end unless source.exist? diff --git a/Library/Homebrew/cask/lib/hbc/cli/install.rb b/Library/Homebrew/cask/lib/hbc/cli/install.rb index 3e9ce4e4f6..3f4c94b6b3 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/install.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/install.rb @@ -35,6 +35,8 @@ module Hbc rescue CaskNoShasumError => e opoo e.message count += 1 + rescue CaskError => e + onoe e.message end end count.zero? ? nil : count == cask_tokens.length