Merge pull request #16977 from Homebrew/cleanup-fixes

cleanup: fix various cases where cache wasn't being removed properly
This commit is contained in:
Bo Anderson 2024-03-31 19:27:56 +01:00 committed by GitHub
commit da456da315
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 9 deletions

View File

@ -134,6 +134,14 @@ module Homebrew
nil nil
end end
if formula.blank? && formula_name.delete_suffix!("_bottle_manifest")
formula = begin
Formulary.from_rack(HOMEBREW_CELLAR/formula_name)
rescue FormulaUnavailableError, TapFormulaAmbiguityError
nil
end
end
return false if formula.blank? return false if formula.blank?
resource_name = basename_str[/\A.*?--(.*?)--?(?:#{Regexp.escape(version.to_s)})/, 1] resource_name = basename_str[/\A.*?--(.*?)--?(?:#{Regexp.escape(version.to_s)})/, 1]
@ -143,7 +151,7 @@ module Homebrew
return true unless patch_hashes&.include?(Checksum.new(version.to_s)) return true unless patch_hashes&.include?(Checksum.new(version.to_s))
elsif resource_name && (resource_version = formula.stable&.resources&.dig(resource_name)&.version) elsif resource_name && (resource_version = formula.stable&.resources&.dig(resource_name)&.version)
return true if resource_version != version return true if resource_version != version
elsif formula.version > version elsif (formula.latest_version_installed? && formula.version != version) || formula.version > version
return true return true
end end
@ -328,7 +336,7 @@ module Homebrew
def cleanup_formula(formula, quiet: false, ds_store: true, cache_db: true) def cleanup_formula(formula, quiet: false, ds_store: true, cache_db: true)
formula.eligible_kegs_for_cleanup(quiet:) formula.eligible_kegs_for_cleanup(quiet:)
.each(&method(:cleanup_keg)) .each(&method(:cleanup_keg))
cleanup_cache(Pathname.glob(cache/"#{formula.name}--*").map { |path| { path:, type: nil } }) cleanup_cache(Pathname.glob(cache/"#{formula.name}{_bottle_manifest,}--*").map { |path| { path:, type: nil } })
rm_ds_store([formula.rack]) if ds_store rm_ds_store([formula.rack]) if ds_store
cleanup_cache_db(formula.rack) if cache_db cleanup_cache_db(formula.rack) if cache_db
cleanup_lockfiles(FormulaLock.new(formula.name).path) cleanup_lockfiles(FormulaLock.new(formula.name).path)

View File

@ -340,7 +340,7 @@ class Bottle
extend Forwardable extend Forwardable
attr_reader :name, :resource, :cellar, :rebuild attr_reader :name, :resource, :tag, :cellar, :rebuild
def_delegators :resource, :url, :verify_download_integrity def_delegators :resource, :url, :verify_download_integrity
def_delegators :resource, :cached_download def_delegators :resource, :cached_download

View File

@ -33,16 +33,15 @@ module Utils
end end
def file_outdated?(formula, file) def file_outdated?(formula, file)
file = file.resolved_path
filename = file.basename.to_s filename = file.basename.to_s
return false if formula.bottle.blank? return false if formula.bottle.blank?
bottle_ext, bottle_tag, = extname_tag_rebuild(filename) _, bottle_tag, bottle_rebuild = extname_tag_rebuild(filename)
return false if bottle_ext.blank? return false if bottle_tag.blank?
return false if bottle_tag != tag.to_s
bottle_url_ext, = extname_tag_rebuild(formula.bottle.url) bottle_tag != formula.bottle.tag.to_s || bottle_rebuild.to_i != formula.bottle.rebuild
bottle_ext && bottle_url_ext && bottle_ext != bottle_url_ext
end end
def extname_tag_rebuild(filename) def extname_tag_rebuild(filename)