From 9e438991c82359d184902a13824c407b429bc33e Mon Sep 17 00:00:00 2001 From: "L. E. Segovia" <13498015+amyspark@users.noreply.github.com> Date: Mon, 8 Oct 2018 09:44:03 +0000 Subject: [PATCH] zip: restore extended attributes when under MacOS --- .../extend/os/mac/unpack_strategy/zip.rb | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/extend/os/mac/unpack_strategy/zip.rb b/Library/Homebrew/extend/os/mac/unpack_strategy/zip.rb index c24d2f14a9..2d0b4618a1 100644 --- a/Library/Homebrew/extend/os/mac/unpack_strategy/zip.rb +++ b/Library/Homebrew/extend/os/mac/unpack_strategy/zip.rb @@ -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?