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
2 changed files with 4 additions and 8 deletions
+2 -5
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
+2 -3
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