Skip to content
Snippets Groups Projects
Commit b3679de3 authored by Vítor Galvão's avatar Vítor Galvão Committed by GitHub
Browse files

Merge pull request #2318 from reitermarkus/remove-old-caskfiles

Remove old metadata when installing with `--force`.
parents 7a8d7823 31d7d6e5
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment