Extract artifact checks to matching_artifact? function.
This commit is contained in:
parent
f97bce040f
commit
432e0c6b5b
@ -42,9 +42,7 @@ module Cask
|
|||||||
end
|
end
|
||||||
|
|
||||||
if Utils.path_occupied?(target)
|
if Utils.path_occupied?(target)
|
||||||
if !predecessor.nil? && target.directory? && target.children.empty? && predecessor.artifacts.any? do |a|
|
if target.directory? && target.children.empty? && matching_artifact?(predecessor)
|
||||||
a.instance_of?(self.class) && instance_of?(a.class) && a.target == target
|
|
||||||
end
|
|
||||||
# An upgrade removed the directory contents but left the directory itself (see below).
|
# An upgrade removed the directory contents but left the directory itself (see below).
|
||||||
unless source.directory?
|
unless source.directory?
|
||||||
if target.parent.writable? && !force
|
if target.parent.writable? && !force
|
||||||
@ -124,6 +122,14 @@ module Cask
|
|||||||
add_altname_metadata(target, source.basename, command: command)
|
add_altname_metadata(target, source.basename, command: command)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def matching_artifact?(cask)
|
||||||
|
return false unless cask
|
||||||
|
|
||||||
|
cask.artifacts.any? do |a|
|
||||||
|
a.instance_of?(self.class) && instance_of?(a.class) && a.target == target
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def move_back(skip: false, force: false, command: nil, **options)
|
def move_back(skip: false, force: false, command: nil, **options)
|
||||||
FileUtils.rm source if source.symlink? && source.dirname.join(source.readlink) == target
|
FileUtils.rm source if source.symlink? && source.dirname.join(source.readlink) == target
|
||||||
|
|
||||||
@ -157,9 +163,7 @@ module Cask
|
|||||||
|
|
||||||
return unless Utils.path_occupied?(target)
|
return unless Utils.path_occupied?(target)
|
||||||
|
|
||||||
if !successor.nil? && target.directory? && successor.artifacts.any? do |a|
|
if target.directory? && matching_artifact?(successor)
|
||||||
a.instance_of?(self.class) && instance_of?(a.class) && a.target == self.target
|
|
||||||
end
|
|
||||||
# If an app folder is deleted, macOS considers the app uninstalled and removes some data.
|
# If an app folder is deleted, macOS considers the app uninstalled and removes some data.
|
||||||
# Remove only the contents to handle this case.
|
# Remove only the contents to handle this case.
|
||||||
target.children.each do |child|
|
target.children.each do |child|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user