diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 2ee605c9a4cf2..d16552fe02954 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 8a44bae259ae5..50e15f4715ae8 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 cd0a64133b19f..d663ec3bab4b3 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 81a9b192ee28c..2fd01ea0e4cfa 100644 --- a/Library/Homebrew/software_spec.rb +++ b/Library/Homebrew/software_spec.rb @@ -352,7 +352,7 @@ def extname attr_reader :name, :resource, :tag, :cellar, :rebuild def_delegators :resource, :url, :verify_download_integrity - def_delegators :resource, :cached_download + def_delegators :resource, :cached_download, :downloader def initialize(formula, spec, tag = nil) super() @@ -408,9 +408,7 @@ def skip_relocation? @spec.skip_relocation?(tag: @tag) end - def stage - resource.downloader.stage - end + def stage = downloader.stage def fetch_tab(timeout: nil, quiet: false) return unless (resource = github_packages_manifest_resource)