BottleAPI: only fetch dependencies if they are outdated locally

This commit is contained in:
Rylan Polster 2021-07-14 02:10:38 -04:00
parent a0f7711ab6
commit 98713e9cd1
No known key found for this signature in database
GPG Key ID: 46A744940CFF4D64
2 changed files with 15 additions and 1 deletions

View File

@ -71,6 +71,14 @@ module BottleAPI
download_bottle(hash, bottle_tag) download_bottle(hash, bottle_tag)
hash["dependencies"].each do |dep_hash| 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) download_bottle(dep_hash, bottle_tag)
end end
end end

View File

@ -520,7 +520,13 @@ class Formula
# exists and is not empty. # exists and is not empty.
# @private # @private
def latest_version_installed? 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 end
# If at least one version of {Formula} is installed. # If at least one version of {Formula} is installed.