Merge pull request #6594 from reitermarkus/tar-dmg

Fix `Dmg` being detected as `Tar`.
This commit is contained in:
Markus Reiter 2019-10-13 22:10:45 +02:00 committed by GitHub
commit eac74ec6e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 8 deletions

View File

@ -106,11 +106,8 @@ module UnpackStrategy
end
def self.can_extract?(path)
imageinfo = system_command("hdiutil",
args: ["imageinfo", path],
print_stderr: false).stdout
!imageinfo.empty?
stdout, _, status = system_command("hdiutil", args: ["imageinfo", path], print_stderr: false)
status.success? && !stdout.empty?
end
private

View File

@ -22,9 +22,8 @@ module UnpackStrategy
return false unless [Bzip2, Gzip, Lzip, Xz].any? { |s| s.can_extract?(path) }
# Check if `tar` can list the contents, then it can also extract it.
IO.popen(["tar", "tf", path], err: File::NULL) do |stdout|
!stdout.read(1).nil?
end
stdout, _, status = system_command("tar", args: ["tf", path], print_stderr: false)
status.success? && !stdout.empty?
end
private