Implement Downloadable
for more types.
This commit is contained in:
parent
e7c9049a3c
commit
404176af1d
@ -296,6 +296,10 @@ module Homebrew
|
||||
|
||||
sleep 0.05
|
||||
rescue Interrupt
|
||||
remaining_downloads.each do |_, future|
|
||||
# FIXME: Implement cancellation of running downloads.
|
||||
end
|
||||
|
||||
print "\n" * previous_pending_line_count
|
||||
$stdout.flush
|
||||
raise
|
||||
|
@ -207,7 +207,6 @@ module Homebrew
|
||||
end
|
||||
|
||||
if casks.any?
|
||||
|
||||
if args.dry_run?
|
||||
if (casks_to_install = casks.reject(&:installed?).presence)
|
||||
ohai "Would install #{::Utils.pluralize("cask", casks_to_install.count, include_count: true)}:"
|
||||
|
@ -710,14 +710,6 @@ class NoUnzipCurlDownloadStrategy < CurlDownloadStrategy
|
||||
end
|
||||
end
|
||||
|
||||
# Strategy for extracting local binary packages.
|
||||
class LocalBottleDownloadStrategy < AbstractFileDownloadStrategy
|
||||
def initialize(path) # rubocop:disable Lint/MissingSuper
|
||||
@cached_location = path
|
||||
extend Pourable
|
||||
end
|
||||
end
|
||||
|
||||
# Strategy for downloading a Subversion repository.
|
||||
#
|
||||
# @api public
|
||||
|
@ -126,7 +126,7 @@ module Downloadable
|
||||
|
||||
sig { overridable.returns(String) }
|
||||
def download_name
|
||||
File.basename(determine_url.to_s)
|
||||
@download_name ||= File.basename(determine_url.to_s)
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -2773,10 +2773,12 @@ class Formula
|
||||
).returns(Pathname)
|
||||
}
|
||||
def fetch(verify_download_integrity: true, timeout: nil, quiet: false)
|
||||
odeprecated "Formula#fetch", "Resource#fetch on Formula#resource"
|
||||
active_spec.fetch(verify_download_integrity:, timeout:, quiet:)
|
||||
end
|
||||
|
||||
def verify_download_integrity(filename)
|
||||
odeprecated "Formula#verify_download_integrity", "Resource#verify_download_integrity on Formula#resource"
|
||||
active_spec.verify_download_integrity(filename)
|
||||
end
|
||||
|
||||
|
@ -1261,11 +1261,11 @@ on_request: installed_on_request?, options:)
|
||||
|
||||
def downloader
|
||||
if (bottle_path = formula.local_bottle_path)
|
||||
LocalBottleDownloadStrategy.new(bottle_path)
|
||||
Resource::Local.new(bottle_path)
|
||||
elsif pour_bottle?
|
||||
formula.bottle
|
||||
else
|
||||
formula
|
||||
formula.resource
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -269,6 +269,33 @@ class Resource
|
||||
[*extra_urls, *super].uniq
|
||||
end
|
||||
|
||||
# A local resource that doesn't need to be downloaded.
|
||||
class Local < Resource
|
||||
def initialize(path)
|
||||
super(File.basename(path))
|
||||
@path = path
|
||||
end
|
||||
|
||||
sig { override.returns(Pathname) }
|
||||
def cached_download
|
||||
@path
|
||||
end
|
||||
|
||||
sig { override.void }
|
||||
def clear_cache; end
|
||||
|
||||
sig {
|
||||
override.params(
|
||||
verify_download_integrity: T::Boolean,
|
||||
timeout: T.nilable(T.any(Integer, Float)),
|
||||
quiet: T::Boolean,
|
||||
).returns(Pathname)
|
||||
}
|
||||
def fetch(verify_download_integrity: true, timeout: nil, quiet: false)
|
||||
cached_download
|
||||
end
|
||||
end
|
||||
|
||||
# A resource for a formula.
|
||||
class Formula < Resource
|
||||
sig { override.returns(String) }
|
||||
|
Loading…
x
Reference in New Issue
Block a user