utils/tar: fix validation for tar without directory or extensions

This commit is contained in:
Michael Cho 2021-05-31 12:37:25 -07:00
parent 5115cc25fa
commit 9e29c6eac2
No known key found for this signature in database
GPG Key ID: F0487049DAE15338

View File

@ -1,6 +1,8 @@
# typed: true
# frozen_string_literal: true
require "system_command"
module Utils
# Helper functions for interacting with tar files.
#
@ -26,9 +28,9 @@ module Utils
path = Pathname.new(path)
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
def clear_executable_cache