aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorL. E. Segovia2017-11-28 18:03:57 +0000
committerL. E. Segovia2017-11-28 18:03:57 +0000
commit9227c8fe3c09cecf551cca060ee45c37cfc30be6 (patch)
tree5a06fe11352543e05f970f45e88cbd8ebac0319c /Library
parent9458e985b79d4c9fca78ed0beab07a5c72d31c3e (diff)
downloadbrew-9227c8fe3c09cecf551cca060ee45c37cfc30be6.tar.bz2
Try #2 at handling backed up Casks
Avoid using variables altogether; fork out the purge into two specialized + one common function
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cask/lib/hbc/installer.rb33
1 files changed, 17 insertions, 16 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/installer.rb b/Library/Homebrew/cask/lib/hbc/installer.rb
index ca13f7eed..83dcf2a55 100644
--- a/Library/Homebrew/cask/lib/hbc/installer.rb
+++ b/Library/Homebrew/cask/lib/hbc/installer.rb
@@ -29,7 +29,6 @@ module Hbc
@require_sha = require_sha
@reinstall = false
@upgrade = upgrade
- @backed_up = false
end
attr_predicate :binaries?, :force?, :skip_cask_deps?, :require_sha?, :upgrade?, :verbose?, :backed_up?
@@ -383,7 +382,6 @@ module Hbc
end
def backup
- @backed_up = true
@cask.staged_path.rename backup_path
end
@@ -393,7 +391,6 @@ module Hbc
Pathname.new(@cask.staged_path).rmtree if @cask.staged_path.exist?
backup_path.rename @cask.staged_path
- @backed_up = false
end
def revert_upgrade
@@ -404,7 +401,7 @@ module Hbc
end
def finalize_upgrade
- purge_versioned_files
+ purge_backed_versioned_files
puts summary
end
@@ -439,11 +436,7 @@ module Hbc
def backup_path
return nil if @cask.staged_path.nil?
- if backed_up?
- Pathname.new "#{@cask.staged_path}.upgrading"
- else
- @cask.staged_path
- end
+ Pathname.new "#{@cask.staged_path}.upgrading"
end
def version_is_latest?
@@ -454,19 +447,27 @@ module Hbc
Utils.gain_permissions_remove(path, command: @command)
end
- def purge_versioned_files
+ def purge_backed_versioned_files
ohai "Purging files for version #{@cask.version} of Cask #{@cask}"
# versioned staged distribution
- if upgrade?
- staged_path = backup_path
- else
- staged_path = @cask.staged_path
- end
+ gain_permissions_remove(backup_path) if !backup_path.nil? && backup_path.exist?
- gain_permissions_remove(staged_path) if !staged_path.nil? && staged_path.exist?
+ # Homebrew-Cask metadata
+ purge_metadata
+ end
+
+ def purge_versioned_files
+ ohai "Purging files for version #{@cask.version} of Cask #{@cask}"
+
+ # versioned staged distribution
+ gain_permissions_remove(@cask.staged_path) if !@cask.staged_path.nil? && @cask.staged_path.exist?
# Homebrew-Cask metadata
+ purge_metadata
+ end
+
+ def purge_metadata
if @cask.metadata_versioned_path.respond_to?(:children) &&
@cask.metadata_versioned_path.exist? &&
!(upgrade? && version_is_latest?)