From 4da5c09c256accf5eb25101764310acc365172ce Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Thu, 7 May 2020 09:58:27 +0100 Subject: [PATCH] cleanup: tweak missing clean file behaviour. Instead of cleaning every time if the file is missing: don't clean this time, touch the file and clean when it's next needed. Now that this feature has been around for longer this makes more sense for existing installations and stops the first `brew install` run on a new/test installation without this file always running a `brew cleanup`. Also, fix up the use of a compat/deprecated method hit by tests by this change. --- Library/Homebrew/cleanup.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/cleanup.rb b/Library/Homebrew/cleanup.rb index cc12be3886..480a9c9ca1 100644 --- a/Library/Homebrew/cleanup.rb +++ b/Library/Homebrew/cleanup.rb @@ -142,14 +142,18 @@ module Homebrew cleanup = Cleanup.new if cleanup.periodic_clean_due? cleanup.periodic_clean! - elsif f.installed? + elsif f.latest_version_installed? cleanup.cleanup_formula(f) end end def periodic_clean_due? return false if Homebrew::EnvConfig.no_install_cleanup? - return true unless PERIODIC_CLEAN_FILE.exist? + + unless PERIODIC_CLEAN_FILE.exist? + FileUtils.touch PERIODIC_CLEAN_FILE + return false + end PERIODIC_CLEAN_FILE.mtime < CLEANUP_DEFAULT_DAYS.days.ago end