zip: restore extended attributes when under MacOS

This commit is contained in:
L. E. Segovia 2018-10-08 09:44:03 +00:00
parent 3fd75bb28b
commit 9e438991c8
No known key found for this signature in database
GPG Key ID: D5D1DC48B52B7AD5

View File

@ -2,10 +2,21 @@ module UnpackStrategy
class Zip
prepend Module.new {
def extract_to_dir(unpack_dir, basename:, verbose:)
volumes = super.stderr.chomp
.split("\n")
.map { |l| l[/\A skipping: (.+) volume label\Z/, 1] }
.compact
result = super
volumes = result.stderr.chomp
.split("\n")
.map { |l| l[/\A skipping: (.+) volume label\Z/, 1] }
.compact
if result.stderr.lines.any? { |line| line.start_with?("._") }
# Merge ._ files back into extended attributes.
# ._ files inside volumes are automatically merged by ditto.
system_command!("dot_clean",
args: ["-mv", "--keep=dotbar", unpack_dir],
verbose: verbose,
print_stderr: false)
end
return if volumes.empty?