utils/tar: fix validation for tar without directory or extensions
This commit is contained in:
parent
5115cc25fa
commit
9e29c6eac2
@ -1,6 +1,8 @@
|
|||||||
# typed: true
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "system_command"
|
||||||
|
|
||||||
module Utils
|
module Utils
|
||||||
# Helper functions for interacting with tar files.
|
# Helper functions for interacting with tar files.
|
||||||
#
|
#
|
||||||
@ -26,9 +28,9 @@ module Utils
|
|||||||
|
|
||||||
path = Pathname.new(path)
|
path = Pathname.new(path)
|
||||||
return unless TAR_FILE_EXTENSIONS.include? path.extname
|
return unless TAR_FILE_EXTENSIONS.include? path.extname
|
||||||
return if Utils.popen_read(executable, "--list", "--file", path).match?(%r{/.*\.})
|
|
||||||
|
|
||||||
odie "#{path} is not a valid tar file!"
|
stdout, _, status = system_command(executable, args: ["--list", "--file", path], print_stderr: false)
|
||||||
|
odie "#{path} is not a valid tar file!" if !status.success? || stdout.blank?
|
||||||
end
|
end
|
||||||
|
|
||||||
def clear_executable_cache
|
def clear_executable_cache
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user