formula_installer: use cached fetched formula instance when available

This commit is contained in:
Bo Anderson 2023-07-28 02:12:09 +01:00
parent 3d44b93116
commit dcbdc73c45
No known key found for this signature in database
GPG Key ID: 3DB94E204E137D65

View File

@ -96,6 +96,9 @@ class FormulaInstaller
@requirement_messages = [] @requirement_messages = []
@poured_bottle = false @poured_bottle = false
@start_time = nil @start_time = nil
# Take the original formula instance, which might have been swapped from an API instance to a source instance
@formula = previously_fetched_formula if previously_fetched_formula
end end
def self.attempted def self.attempted
@ -1179,9 +1182,17 @@ on_request: installed_on_request?, options: options)
deps.each { |dep, _options| fetch_dependency(dep) } deps.each { |dep, _options| fetch_dependency(dep) }
end end
sig { returns(T.nilable(Formula)) }
def previously_fetched_formula
# We intentionally don't compare classes here.
self.class.fetched.find do |fetched_formula|
fetched_formula.full_name == formula.full_name && fetched_formula.active_spec_sym == formula.active_spec_sym
end
end
sig { void } sig { void }
def fetch def fetch
return if self.class.fetched.include?(formula) return if previously_fetched_formula
fetch_dependencies fetch_dependencies