aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew
diff options
context:
space:
mode:
authorVítor Galvão2017-03-12 02:54:05 +0000
committerGitHub2017-03-12 02:54:05 +0000
commitb3679de310609f7cacfbb83331ec54582e1c395f (patch)
tree1a2075a009e62e607ccab1d6565ec7bccf6d59a7 /Library/Homebrew
parent7a8d782365b615e066bead9b4829f6fce7f375df (diff)
parent31d7d6e5f3ec88ffbaf8aa86ac6239e79cd9d160 (diff)
downloadbrew-b3679de310609f7cacfbb83331ec54582e1c395f.tar.bz2
Merge pull request #2318 from reitermarkus/remove-old-caskfiles
Remove old metadata when installing with `--force`.
Diffstat (limited to 'Library/Homebrew')
-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