aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMarkus Reiter2017-03-11 18:55:16 +0100
committerMarkus Reiter2017-03-11 21:09:13 +0100
commit31d7d6e5f3ec88ffbaf8aa86ac6239e79cd9d160 (patch)
tree0f08a71eb22481546234dc18804d426786520b54 /Library
parent666ab1438c0aba8d4c0f4b540a5ccdba485f0eca (diff)
downloadbrew-31d7d6e5f3ec88ffbaf8aa86ac6239e79cd9d160.tar.bz2
Remove old metadata when installing with `--force`.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cask/lib/hbc/cask.rb1
-rw-r--r--Library/Homebrew/cask/lib/hbc/installer.rb17
2 files changed, 8 insertions, 10 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/cask.rb b/Library/Homebrew/cask/lib/hbc/cask.rb
index 52dd676b4..975d69d07 100644
--- a/Library/Homebrew/cask/lib/hbc/cask.rb
+++ b/Library/Homebrew/cask/lib/hbc/cask.rb
@@ -32,7 +32,6 @@ module Hbc
end
def metadata_path(timestamp = :latest, create = false)
- return nil unless metadata_versioned_container_path.respond_to?(:join)
if create && timestamp == :latest
raise CaskError, "Cannot create metadata path when timestamp is :latest"
end
diff --git a/Library/Homebrew/cask/lib/hbc/installer.rb b/Library/Homebrew/cask/lib/hbc/installer.rb
index b86f3264d..94d270946 100644
--- a/Library/Homebrew/cask/lib/hbc/installer.rb
+++ b/Library/Homebrew/cask/lib/hbc/installer.rb
@@ -295,16 +295,15 @@ module Hbc
end
def save_caskfile
- timestamp = :now
- create = true
- savedir = @cask.metadata_subdir("Casks", timestamp, create)
- if Dir.entries(savedir).size > 2
- # should not happen
- raise CaskAlreadyInstalledError, @cask unless force
- savedir.rmtree
- FileUtils.mkdir_p savedir
+ unless (old_savedirs = Pathname.glob(@cask.metadata_path("*"))).empty?
+ old_savedirs.each(&:rmtree)
end
- FileUtils.copy(@cask.sourcefile_path, savedir) if @cask.sourcefile_path
+
+ return unless @cask.sourcefile_path
+
+ savedir = @cask.metadata_subdir("Casks", :now, true)
+ savedir.mkpath
+ FileUtils.copy @cask.sourcefile_path, savedir
end
def uninstall