Fix Dmg being detected as Tar.

This commit is contained in:
Markus Reiter 2019-10-13 17:19:02 +02:00
parent 16d477c696
commit 67d51ef0e1
2 changed files with 4 additions and 8 deletions

View File

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

View File

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