From aa6f10ff356e6bae2b53ee1c7cdafa26aa4c3ded Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?fn=20=E2=8C=83=20=E2=8C=A5?= <70830482+FnControlOption@users.noreply.github.com> Date: Sun, 31 Oct 2021 10:52:40 -0700 Subject: [PATCH] install, upgrade: fetch each formula only once --- Library/Homebrew/formula_installer.rb | 13 +++++++++++++ Library/Homebrew/test/spec_helper.rb | 1 + 2 files changed, 14 insertions(+) diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index cab34ccc8c..ffdeed7af5 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -114,6 +114,15 @@ class FormulaInstaller @installed = Set.new end + def self.fetched + @fetched ||= Set.new + end + + sig { void } + def self.clear_fetched + @fetched = Set.new + end + sig { returns(T::Boolean) } def build_from_source? @build_from_source_formulae.include?(formula.full_name) @@ -1141,6 +1150,8 @@ class FormulaInstaller sig { void } def fetch + return if self.class.fetched.include?(formula) + fetch_dependencies return if only_deps? @@ -1152,6 +1163,8 @@ class FormulaInstaller formula.resources.each(&:fetch) end downloader.fetch + + self.class.fetched << formula end def downloader diff --git a/Library/Homebrew/test/spec_helper.rb b/Library/Homebrew/test/spec_helper.rb index 2bc564f8c1..cca75d7834 100644 --- a/Library/Homebrew/test/spec_helper.rb +++ b/Library/Homebrew/test/spec_helper.rb @@ -204,6 +204,7 @@ RSpec.configure do |config| Requirement.clear_cache FormulaInstaller.clear_attempted FormulaInstaller.clear_installed + FormulaInstaller.clear_fetched TEST_DIRECTORIES.each(&:mkpath)