Only merge extended attributes if required
This commit is contained in:
parent
e09d4336a9
commit
c6894a23c1
@ -161,7 +161,7 @@ module Cask
|
||||
|
||||
def primary_container
|
||||
@primary_container ||= begin
|
||||
UnpackStrategy.detect(@downloaded_path, type: @cask.container&.type)
|
||||
UnpackStrategy.detect(@downloaded_path, type: @cask.container&.type, merge_xattrs: true)
|
||||
end
|
||||
end
|
||||
|
||||
@ -179,7 +179,7 @@ module Cask
|
||||
|
||||
FileUtils.chmod_R "+rw", tmpdir/nested_container, force: true, verbose: verbose?
|
||||
|
||||
UnpackStrategy.detect(tmpdir/nested_container)
|
||||
UnpackStrategy.detect(tmpdir/nested_container, merge_xattrs: true)
|
||||
.extract_nestedly(to: @cask.staged_path, verbose: verbose?)
|
||||
end
|
||||
else
|
||||
|
||||
@ -2,6 +2,16 @@ module UnpackStrategy
|
||||
class Zip
|
||||
prepend Module.new {
|
||||
def extract_to_dir(unpack_dir, basename:, verbose:)
|
||||
if merge_xattrs && contains_extended_attributes?(path)
|
||||
# We use ditto directly, because dot_clean has issues if the __MACOSX
|
||||
# folder has incorrect permissions.
|
||||
# (Also, Homebrew's ZIP artifact automatically deletes this folder.)
|
||||
return system_command! "ditto",
|
||||
args: ["-x", "-k", path, unpack_dir],
|
||||
verbose: verbose,
|
||||
print_stderr: false
|
||||
end
|
||||
|
||||
result = begin
|
||||
super
|
||||
rescue ErrorDuringExecution => e
|
||||
@ -13,18 +23,6 @@ module UnpackStrategy
|
||||
return
|
||||
end
|
||||
|
||||
if contains_extended_attributes?(path)
|
||||
# Merge ._ files back into extended attributes.
|
||||
# We use ditto, because dot_clean has issues if the __MACOSX
|
||||
# folder has incorrect permissions.
|
||||
# (Also, Homebrew's ZIP artifact automatically deletes this folder.)
|
||||
system_command! "ditto",
|
||||
args: ["-x", "-k", path, unpack_dir],
|
||||
verbose: verbose,
|
||||
print_stderr: false
|
||||
return
|
||||
end
|
||||
|
||||
volumes = result.stderr.chomp
|
||||
.split("\n")
|
||||
.map { |l| l[/\A skipping: (.+) volume label\Z/, 1] }
|
||||
|
||||
@ -88,7 +88,7 @@ module UnpackStrategy
|
||||
strategies.find { |s| s.can_extract?(path) }
|
||||
end
|
||||
|
||||
def self.detect(path, prioritise_extension: false, type: nil, ref_type: nil, ref: nil)
|
||||
def self.detect(path, prioritise_extension: false, type: nil, ref_type: nil, ref: nil, merge_xattrs: nil)
|
||||
strategy = from_type(type) if type
|
||||
|
||||
if prioritise_extension && path.extname.present?
|
||||
@ -102,15 +102,16 @@ module UnpackStrategy
|
||||
|
||||
strategy ||= Uncompressed
|
||||
|
||||
strategy.new(path, ref_type: ref_type, ref: ref)
|
||||
strategy.new(path, ref_type: ref_type, ref: ref, merge_xattrs: merge_xattrs)
|
||||
end
|
||||
|
||||
attr_reader :path
|
||||
attr_reader :path, :merge_xattrs
|
||||
|
||||
def initialize(path, ref_type: nil, ref: nil)
|
||||
def initialize(path, ref_type: nil, ref: nil, merge_xattrs: nil)
|
||||
@path = Pathname(path).expand_path
|
||||
@ref_type = ref_type
|
||||
@ref = ref
|
||||
@merge_xattrs = merge_xattrs
|
||||
end
|
||||
|
||||
def extract(to: nil, basename: nil, verbose: false)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user