From eb5c0351cdf6c2c920a9bff2417c4c923d6a1a4b Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 4 Sep 2024 23:12:58 +0200 Subject: [PATCH] Fix wrong `stage` method being called. --- Library/Homebrew/download_strategy.rb | 11 +++++++++++ Library/Homebrew/formula_installer.rb | 6 +++--- Library/Homebrew/resource.rb | 21 +-------------------- Library/Homebrew/software_spec.rb | 4 +--- 4 files changed, 16 insertions(+), 26 deletions(-) diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 2ee605c9a4cf24..d16552fe02954e 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -710,6 +710,17 @@ def stage end end +# Strategy for extracting local binary packages. +class LocalBottleDownloadStrategy < AbstractFileDownloadStrategy + def initialize(path) # rubocop:disable Lint/MissingSuper + @cached_location = path + end + + def clear_cache + # Path is used directly and not cached. + end +end + # Strategy for downloading a Subversion repository. # # @api public diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 8a44bae259ae53..50e15f4715ae8d 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -1254,12 +1254,12 @@ def fetch formula.fetch_patches formula.resources.each(&:fetch) end - downloader.fetch + downloadable.downloader.fetch self.class.fetched << formula end - def downloader + def downloadable if (bottle_path = formula.local_bottle_path) Resource::Local.new(bottle_path) elsif pour_bottle? @@ -1324,7 +1324,7 @@ def pour end HOMEBREW_CELLAR.cd do - downloader.stage + downloadable.downloader.stage end Tab.clear_cache diff --git a/Library/Homebrew/resource.rb b/Library/Homebrew/resource.rb index cd0a64133b19f9..d663ec3bab4b39 100644 --- a/Library/Homebrew/resource.rb +++ b/Library/Homebrew/resource.rb @@ -273,26 +273,7 @@ def determine_url_mirrors 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 + @downloader = LocalBottleDownloadStrategy.new(path) end end diff --git a/Library/Homebrew/software_spec.rb b/Library/Homebrew/software_spec.rb index 81a9b192ee28ce..75ab4b89a06406 100644 --- a/Library/Homebrew/software_spec.rb +++ b/Library/Homebrew/software_spec.rb @@ -408,9 +408,7 @@ def skip_relocation? @spec.skip_relocation?(tag: @tag) end - def stage - resource.downloader.stage - end + def stage = resource.downloader.stage def fetch_tab(timeout: nil, quiet: false) return unless (resource = github_packages_manifest_resource)