Also keep app directories with "brew reinstall".
This commit is contained in:
parent
5c9fa845a8
commit
dcc4ae76e8
@ -270,8 +270,8 @@ module Cask
|
||||
end
|
||||
end
|
||||
|
||||
def uninstall_login_item(*login_items, command: nil, upgrade: false, **_)
|
||||
return if upgrade
|
||||
def uninstall_login_item(*login_items, command: nil, upgrade_or_reinstall: false, **_)
|
||||
return if upgrade_or_reinstall
|
||||
|
||||
apps = cask.artifacts.select { |a| a.class.dsl_key == :app }
|
||||
derived_login_items = apps.map { |a| { path: a.target } }
|
||||
|
@ -35,13 +35,14 @@ module Cask
|
||||
|
||||
private
|
||||
|
||||
def move(adopt: false, force: false, verbose: false, upgrade: false, command: nil, **options)
|
||||
def move(adopt: false, force: false, verbose: false, upgrade_or_reinstall: false, reinstall: false,
|
||||
command: nil, **options)
|
||||
unless source.exist?
|
||||
raise CaskError, "It seems the #{self.class.english_name} source '#{source}' is not there."
|
||||
end
|
||||
|
||||
if Utils.path_occupied?(target)
|
||||
if upgrade && target.directory? && target.children.empty?
|
||||
if upgrade_or_reinstall && target.directory? && target.children.empty?
|
||||
# An upgrade removed the directory contents but left the directory itself (see below).
|
||||
unless source.directory?
|
||||
if target.parent.writable? && !force
|
||||
@ -148,13 +149,13 @@ module Cask
|
||||
delete(target, force: force, command: command, **options)
|
||||
end
|
||||
|
||||
def delete(target, force: false, upgrade: false, command: nil, **_)
|
||||
def delete(target, force: false, upgrade_or_reinstall: false, command: nil, **_)
|
||||
ohai "Removing #{self.class.english_name} '#{target}'"
|
||||
raise CaskError, "Cannot remove undeletable #{self.class.english_name}." if MacOS.undeletable?(target)
|
||||
|
||||
return unless Utils.path_occupied?(target)
|
||||
|
||||
if upgrade && target.directory?
|
||||
if upgrade_or_reinstall && target.directory?
|
||||
# If an app folder is deleted, macOS considers the app uninstalled and removes some data.
|
||||
# Remove only the contents to handle this case.
|
||||
target.children.each do |child|
|
||||
|
@ -41,6 +41,7 @@ module Cask
|
||||
force: force,
|
||||
skip_cask_deps: skip_cask_deps,
|
||||
require_sha: require_sha,
|
||||
reinstall: true,
|
||||
quarantine: quarantine,
|
||||
zap: zap,
|
||||
}.compact
|
||||
@ -48,7 +49,7 @@ module Cask
|
||||
options[:quarantine] = true if options[:quarantine].nil?
|
||||
|
||||
casks.each do |cask|
|
||||
Installer.new(cask, **options).reinstall
|
||||
Installer.new(cask, **options).install
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -22,7 +22,7 @@ module Cask
|
||||
|
||||
def initialize(cask, command: SystemCommand, force: false, adopt: false,
|
||||
skip_cask_deps: false, binaries: true, verbose: false,
|
||||
zap: false, require_sha: false, upgrade: false,
|
||||
zap: false, require_sha: false, upgrade: false, reinstall: false,
|
||||
installed_as_dependency: false, quarantine: true,
|
||||
verify_download_integrity: true, quiet: false)
|
||||
@cask = cask
|
||||
@ -34,7 +34,7 @@ module Cask
|
||||
@verbose = verbose
|
||||
@zap = zap
|
||||
@require_sha = require_sha
|
||||
@reinstall = false
|
||||
@reinstall = reinstall
|
||||
@upgrade = upgrade
|
||||
@installed_as_dependency = installed_as_dependency
|
||||
@quarantine = quarantine
|
||||
@ -143,17 +143,11 @@ on_request: true)
|
||||
end
|
||||
end
|
||||
|
||||
def reinstall
|
||||
odebug "Cask::Installer#reinstall"
|
||||
@reinstall = true
|
||||
install
|
||||
end
|
||||
|
||||
def uninstall_existing_cask
|
||||
return unless @cask.installed?
|
||||
|
||||
# Always force uninstallation, ignore method parameter
|
||||
cask_installer = Installer.new(@cask, verbose: verbose?, force: true, upgrade: upgrade?)
|
||||
cask_installer = Installer.new(@cask, verbose: verbose?, force: true, upgrade: upgrade?, reinstall: true)
|
||||
zap? ? cask_installer.zap : cask_installer.uninstall
|
||||
end
|
||||
|
||||
@ -234,7 +228,8 @@ on_request: true)
|
||||
|
||||
next if artifact.is_a?(Artifact::Binary) && !binaries?
|
||||
|
||||
artifact.install_phase(command: @command, verbose: verbose?, adopt: adopt?, force: force?, upgrade: upgrade?)
|
||||
artifact.install_phase(command: @command, verbose: verbose?, adopt: adopt?, force: force?,
|
||||
upgrade_or_reinstall: upgrade? || reinstall?)
|
||||
already_installed_artifacts.unshift(artifact)
|
||||
end
|
||||
|
||||
@ -461,7 +456,11 @@ on_request: true)
|
||||
if artifact.respond_to?(:uninstall_phase)
|
||||
odebug "Uninstalling artifact of class #{artifact.class}"
|
||||
artifact.uninstall_phase(
|
||||
command: @command, verbose: verbose?, skip: clear, force: force?, upgrade: upgrade?,
|
||||
command: @command,
|
||||
verbose: verbose?,
|
||||
skip: clear,
|
||||
force: force?,
|
||||
upgrade_or_reinstall: upgrade? || reinstall?,
|
||||
)
|
||||
end
|
||||
|
||||
@ -469,7 +468,11 @@ on_request: true)
|
||||
|
||||
odebug "Post-uninstalling artifact of class #{artifact.class}"
|
||||
artifact.post_uninstall_phase(
|
||||
command: @command, verbose: verbose?, skip: clear, force: force?, upgrade: upgrade?,
|
||||
command: @command,
|
||||
verbose: verbose?,
|
||||
skip: clear,
|
||||
force: force?,
|
||||
upgrade_or_reinstall: upgrade? || reinstall?,
|
||||
)
|
||||
end
|
||||
end
|
||||
|
@ -323,13 +323,13 @@ describe Cask::Artifact::App, :cask do
|
||||
inode = target_path.stat.ino
|
||||
expect(contents_path).to exist
|
||||
|
||||
app.uninstall_phase(command: command, force: force, upgrade: true)
|
||||
app.uninstall_phase(command: command, force: force, upgrade_or_reinstall: true)
|
||||
|
||||
expect(target_path).to exist
|
||||
expect(target_path.children).to be_empty
|
||||
expect(contents_path).not_to exist
|
||||
|
||||
app.install_phase(command: command, adopt: adopt, force: force, upgrade: true)
|
||||
app.install_phase(command: command, adopt: adopt, force: force, upgrade_or_reinstall: true)
|
||||
expect(target_path).to exist
|
||||
expect(target_path.stat.ino).to eq(inode)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user