Merge pull request #5977 from MikeMcQuaid/unpack_strategy_prioritise_extension
unpack_strategy: prioritise extension instead.
This commit is contained in:
commit
bf9aae39a1
@ -54,11 +54,11 @@ class AbstractDownloadStrategy
|
||||
# Unlike {Resource#stage}, this does not take a block.
|
||||
def stage
|
||||
UnpackStrategy.detect(cached_location,
|
||||
extension_only: true,
|
||||
prioritise_extension: true,
|
||||
ref_type: @ref_type, ref: @ref)
|
||||
.extract_nestedly(basename: basename,
|
||||
extension_only: true,
|
||||
verbose: ARGV.verbose? && !shutup)
|
||||
.extract_nestedly(basename: basename,
|
||||
prioritise_extension: true,
|
||||
verbose: ARGV.verbose? && !shutup)
|
||||
chdir
|
||||
end
|
||||
|
||||
|
@ -88,10 +88,10 @@ module UnpackStrategy
|
||||
strategies.find { |s| s.can_extract?(path) }
|
||||
end
|
||||
|
||||
def self.detect(path, extension_only: false, type: nil, ref_type: nil, ref: nil)
|
||||
def self.detect(path, prioritise_extension: false, type: nil, ref_type: nil, ref: nil)
|
||||
strategy = from_type(type) if type
|
||||
|
||||
if extension_only
|
||||
if prioritise_extension && path.extname.present?
|
||||
strategy ||= from_extension(path.extname)
|
||||
strategy ||= strategies.select { |s| s < Directory || s == Fossil }
|
||||
.find { |s| s.can_extract?(path) }
|
||||
@ -120,7 +120,7 @@ module UnpackStrategy
|
||||
extract_to_dir(unpack_dir, basename: basename, verbose: verbose)
|
||||
end
|
||||
|
||||
def extract_nestedly(to: nil, basename: nil, verbose: false, extension_only: false)
|
||||
def extract_nestedly(to: nil, basename: nil, verbose: false, prioritise_extension: false)
|
||||
Dir.mktmpdir do |tmp_unpack_dir|
|
||||
tmp_unpack_dir = Pathname(tmp_unpack_dir)
|
||||
|
||||
@ -131,9 +131,9 @@ module UnpackStrategy
|
||||
if children.count == 1 && !children.first.directory?
|
||||
FileUtils.chmod "+rw", children.first, verbose: verbose
|
||||
|
||||
s = UnpackStrategy.detect(children.first, extension_only: extension_only)
|
||||
s = UnpackStrategy.detect(children.first, prioritise_extension: prioritise_extension)
|
||||
|
||||
s.extract_nestedly(to: to, verbose: verbose, extension_only: extension_only)
|
||||
s.extract_nestedly(to: to, verbose: verbose, prioritise_extension: prioritise_extension)
|
||||
next
|
||||
end
|
||||
|
||||
|
@ -2,7 +2,7 @@ module UnpackStrategy
|
||||
class Uncompressed
|
||||
include UnpackStrategy
|
||||
|
||||
def extract_nestedly(extension_only: false, **options)
|
||||
def extract_nestedly(prioritise_extension: false, **options)
|
||||
extract(**options)
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user