From 98713e9cd1613dadf6c8c1f06d7dc6ad63f53d9e Mon Sep 17 00:00:00 2001 From: Rylan Polster Date: Wed, 14 Jul 2021 02:10:38 -0400 Subject: [PATCH] BottleAPI: only fetch dependencies if they are outdated locally --- Library/Homebrew/bottle_api.rb | 8 ++++++++ Library/Homebrew/formula.rb | 8 +++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/bottle_api.rb b/Library/Homebrew/bottle_api.rb index 214e62a73d..2cba314eb7 100644 --- a/Library/Homebrew/bottle_api.rb +++ b/Library/Homebrew/bottle_api.rb @@ -71,6 +71,14 @@ module BottleAPI download_bottle(hash, bottle_tag) hash["dependencies"].each do |dep_hash| + existing_formula = begin + Formulary.factory dep_hash["name"] + rescue FormulaUnavailableError + nil + end + + next if existing_formula.present? && existing_formula.latest_version_installed? + download_bottle(dep_hash, bottle_tag) end end diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 82801da112..f6c3eca64d 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -520,7 +520,13 @@ class Formula # exists and is not empty. # @private def latest_version_installed? - (dir = latest_installed_prefix).directory? && !dir.children.empty? + latest_prefix = if ENV["HOMEBREW_JSON_CORE"].present? + prefix BottleAPI.latest_pkg_version(name) + else + latest_installed_prefix + end + + (dir = latest_prefix).directory? && !dir.children.empty? end # If at least one version of {Formula} is installed.