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