Skip to content

Commit

Permalink
Fix wrong stage method being called.
Browse files Browse the repository at this point in the history
  • Loading branch information
reitermarkus committed Sep 4, 2024
1 parent 231ac72 commit 90ced30
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 28 deletions.
11 changes: 11 additions & 0 deletions Library/Homebrew/download_strategy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions Library/Homebrew/formula_installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down Expand Up @@ -1324,7 +1324,7 @@ def pour
end

HOMEBREW_CELLAR.cd do
downloader.stage
downloadable.downloader.stage
end

Tab.clear_cache
Expand Down
21 changes: 1 addition & 20 deletions Library/Homebrew/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 3 additions & 5 deletions Library/Homebrew/software_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -460,7 +458,7 @@ def github_packages_manifest_resource
using: CurlGitHubPackagesDownloadStrategy,
headers: ["Accept: application/vnd.oci.image.index.v1+json"],
)
T.cast(resource.downloader, CurlGitHubPackagesDownloadStrategy).resolved_basename =
T.cast(downloader, CurlGitHubPackagesDownloadStrategy).resolved_basename =
"#{name}-#{version_rebuild}.bottle_manifest.json"
resource
end
Expand Down

0 comments on commit 90ced30

Please sign in to comment.