diff --git a/Library/Homebrew/cmd/fetch.rb b/Library/Homebrew/cmd/fetch.rb index 0b0018e8a6b07e..359b3c5d2ba2bc 100644 --- a/Library/Homebrew/cmd/fetch.rb +++ b/Library/Homebrew/cmd/fetch.rb @@ -296,6 +296,10 @@ def run 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 diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb index 27a153d5755f86..97bf4d3a8ee945 100644 --- a/Library/Homebrew/cmd/install.rb +++ b/Library/Homebrew/cmd/install.rb @@ -207,7 +207,6 @@ def run 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)}:" diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 39b81a10739a22..2ee605c9a4cf24 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -710,14 +710,6 @@ def stage 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 diff --git a/Library/Homebrew/downloadable.rb b/Library/Homebrew/downloadable.rb index 9afb25d55a313a..a39d5d7b48e8c5 100644 --- a/Library/Homebrew/downloadable.rb +++ b/Library/Homebrew/downloadable.rb @@ -126,7 +126,7 @@ def verify_download_integrity(filename) sig { overridable.returns(String) } def download_name - File.basename(determine_url.to_s) + @download_name ||= File.basename(determine_url.to_s) end private diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 06f111b8612e7f..14d1cd94384f31 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -2773,10 +2773,12 @@ def on_system_blocks_exist? ).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 diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index ec6a4345e0e388..10f6214f9622f4 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -1261,11 +1261,11 @@ def fetch 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 diff --git a/Library/Homebrew/resource.rb b/Library/Homebrew/resource.rb index 8471fbca44f539..cd0a64133b19f9 100644 --- a/Library/Homebrew/resource.rb +++ b/Library/Homebrew/resource.rb @@ -269,6 +269,33 @@ def determine_url_mirrors [*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) }