Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.
Swift cache-cleanercleanerclideveloper-toolsdisk-cleanupdisk-spaceduplicate-finderhomebrewliquid-glassmac-cleanermacosmacos-appmacos-golden-gatemacos-tahoemacos-tweaksswiftswiftuiterminal-themesuninstalluninstaller
Date Homebrew's last check by the definitions it reads
Țugui Dragoșf8451ad7adef
diff --git a/AGENTS.md b/AGENTS.mdindex 1884d366..924e8877 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -301,10 +301,12 @@ If you are unsure whether something belongs in the helper, it doesn't.streams, in the order Homebrew wrote them.- **Never run `brew` by hand with `HOMEBREW_NO_INSTALL_FROM_API=1`**: Homebrew then clones its whole core tap, overa gigabyte. Peel sets it for one question only, whether Homebrew's copy of its definitions is on the Mac.-- **What Homebrew says of versions is as new as its last check for them.** `brew update` touches `.git/FETCH_HEAD` in- Homebrew's repository, the mark Homebrew compares with its own day, and while it reads its definitions from its API- it dates their file at every download or confirmation (`api.rb`), so what it says counts for a day after the later- of the two (`Homebrew.lastUpdateCheck()`, `Homebrew.autoUpdateInterval`), while an update it knows of always shows.+- **What Homebrew says of versions is as new as its last check for them.** While Homebrew reads its definitions from+ its API, as it does by default, it dates their file at every download or confirmation (`api.rb`), and only that date+ says how new they are: `brew update` can touch `.git/FETCH_HEAD` in Homebrew's repository, the mark Homebrew compares+ with its own day, and leave the definitions as they were. What Homebrew says counts for a day after that date, or+ after `FETCH_HEAD` for a Homebrew that reads its taps (`Homebrew.lastUpdateCheck()`, `Homebrew.autoUpdateInterval`),+ while an update it knows of always shows.- **Apple's lookup is limited and lags a release.** Apple limits `itunes.apple.com/lookup` to about 20 calls aminute, so a process asks no faster (`RequestWindow`), and a copy of its catalog can name an older version forhours after a release, so an answer older than an update already found counts as a check that failed.diff --git a/ARCHITECTURE.md b/ARCHITECTURE.mdindex 73cd5321..1e7006a2 100644--- a/ARCHITECTURE.md+++ b/ARCHITECTURE.md@@ -355,28 +355,29 @@ macOS asks the user to approve it once. It talks to the app over XPC.`SUVerifyUpdateBeforeExtraction`, and `SUAllowsAutomaticUpdates` off), the one place Sparkle reads its securitysettings from. It asks on its own only while Check for app updates is on (`OwnUpdateCheck`), and the updateround of the other apps passes over Peel.-- **Updates of other apps.** `UpdateChecker` asks each app's own feed, or the App Store about an app from the App Store,- and uses what Homebrew knows for an app a cask installed: first with Automatic or Homebrew preferred, and under any- choice once the app's own source can't answer, an "up to date" only for a day after Homebrew last checked for new- versions (`Homebrew.lastUpdateCheck`: the time of `.git/FETCH_HEAD` in its repository, which Homebrew itself compares- before updating on its own, or, while it reads its API, the later date of the definitions file it confirms). An answer Homebrew gives in place of the app's own source carries what that source- answered (`UpdateAnswer.standsInFor`, kept in `UpdateMemory`): the source's answer stands again once Homebrew's no- longer counts, the next check follows the source's own count, and an update the source found earlier stays. What- Homebrew's casks and the app's own files decide without a server, and what Homebrew knows where the app's own source- last had no answer (`statusWithoutAsking`), shows as soon as Homebrew is read, and again at every round, an update- Homebrew no longer reports is forgotten then, and Peel reads Homebrew again once it has checked since. From the App- Store it reads the listing of the installed bundle (`AppStoreListing`): the Mac's, which Apple gives for the desktop,- also for an app sold once for iPhone and Mac, or the iPhone and iPad one for an app of those devices installed on the- Mac, at most 20 lookups in any minute in a process, the pace Apple documents for its lookup (`RequestWindow`). An- app that came with macOS or from Setapp gets no feed (`UpdateFeed.detect`, `InstalledApp.isFromSetapp`):- Software Update and Setapp keep them current, whatever feed the bundle carries. A check waits up to 30 seconds for- a Mac just awake to go online, and one made while it isn't online counts for nothing (`UpdateAnswer.wasOffline`):- what was known stays and the app is asked at the next round. Every answer that changes nothing makes the next check- of that app wait longer, up to a week (`UpdateSchedule`), though the first round after Peel opens also asks about- every app whose answer is a day old (`UpdateMemory.isADayOld`). `UpdateMemory` keeps the last answer across- launches, with the revision of the checker that gave it (`UpdateChecker.revision`): an answer an earlier revision- gave about an app it couldn't check, or about one this revision asks nobody about, is dropped, so the app is asked- again at the next round.+- **Updates of other apps.** `UpdateChecker` asks each app's own feed, or the App Store about an app from the App+ Store, and uses what Homebrew knows for an app a cask installed: first with Automatic or Homebrew preferred, and+ under any choice once the app's own source can't answer, an "up to date" only for a day after Homebrew last checked+ for new versions (`Homebrew.lastUpdateCheck`: while it reads its API, the date of the definitions file it downloads+ or confirms, since a fetch of its own repository leaves them as they were; otherwise the time of `.git/FETCH_HEAD`+ in its repository, which Homebrew itself compares before updating on its own). An answer Homebrew gives in place of+ the app's own source carries what that source answered (`UpdateAnswer.standsInFor`, kept in `UpdateMemory`): the+ source's answer stands again once Homebrew's no longer counts, the next check follows the source's own count, and an+ update the source found earlier stays. What Homebrew's casks and the app's own files decide without a server, and+ what Homebrew knows where the app's own source last had no answer (`statusWithoutAsking`), shows as soon as Homebrew+ is read, and again at every round, an update Homebrew no longer reports is forgotten then, and Peel reads Homebrew+ again once it has checked since. From the App Store it reads the listing of the installed bundle+ (`AppStoreListing`): the Mac's, which Apple gives for the desktop, also for an app sold once for iPhone and Mac, or+ the iPhone and iPad one for an app of those devices installed on the Mac, at most 20 lookups in any minute in a+ process, the pace Apple documents for its lookup (`RequestWindow`). An app that came with macOS or from Setapp gets+ no feed (`UpdateFeed.detect`, `InstalledApp.isFromSetapp`): Software Update and Setapp keep them current, whatever+ feed the bundle carries. A check waits up to 30 seconds for a Mac just awake to go online, and one made while it+ isn't online counts for nothing (`UpdateAnswer.wasOffline`): what was known stays and the app is asked at the next+ round. Every answer that changes nothing makes the next check of that app wait longer, up to a week+ (`UpdateSchedule`), though the first round after Peel opens also asks about every app whose answer is a day old+ (`UpdateMemory.isADayOld`). `UpdateMemory` keeps the last answer across launches, with the revision of the checker+ that gave it (`UpdateChecker.revision`): an answer an earlier revision gave about an app it couldn't check, or about+ one this revision asks nobody about, is dropped, so the app is asked again at the next round.- **Orphaned Files.** `OrphanScanner` lists what no installed app claims, under the app Peel saw go when it canname it (`AppMemory`), and selects nothing for the person. An app macOS knows on another disk that claims somethingis remembered too (`OrphanScan.appsOnOtherDisks`, `Disks`), so its files stay its own while that disk isn'tdiff --git a/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift b/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swiftindex 9fa48e12..96ea0840 100644--- a/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift+++ b/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift@@ -696,9 +696,8 @@ public enum Homebrew {}}- /// When Homebrew last checked for new versions: when `brew update` last touched `.git/FETCH_HEAD` in its- /// repository, which Homebrew compares with `HOMEBREW_AUTO_UPDATE_SECS`, or, while it reads its definitions from- /// its API, when it last downloaded or confirmed them, whichever is later. Nil when neither can be found.+ /// When Homebrew last checked for new versions: the date of its definitions file while it reads its API, as by+ /// default, since a fetch of its own code leaves them as they were, else when `.git/FETCH_HEAD` was last touched.@concurrentpublic static func lastUpdateCheck() async -> Date? {guard let answer = try? await answer(["--repository"]), let repository = folder(answering: answer) else {@@ -717,7 +716,7 @@ public enum Homebrew {static func lastUpdateCheck(inRepository repository: URL, cache: URL, readsTheTaps: Bool) -> Date? {let fetched = lastUpdateCheck(inRepository: repository)guard !readsTheTaps else { return fetched }- return ([fetched] + definitionsChecks(inCache: cache)).compactMap(\.self).max()+ return definitionsChecks(inCache: cache).max() ?? fetched}/// The dates of the packages files in Homebrew's API cache, which it sets at every download or revalidationdiff --git a/Packages/PeelCore/Tests/PeelCoreTests/HomebrewTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/HomebrewTests.swiftindex 222494c7..7b1d1354 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/HomebrewTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/HomebrewTests.swift@@ -187,7 +187,7 @@ struct HomebrewTests {#expect(unread?.path(percentEncoded: false) == file.path(percentEncoded: false))}- @Test func takesTheLaterOfAnUpdateAndAConfirmationOfTheDefinitions() throws {+ @Test func datesTheLastCheckByTheDefinitionsHomebrewReadsFromItsAPI() throws {let repository = try TemporaryDirectory()let fetchHead = try repository.file(".git/FETCH_HEAD", contents: Data("main\n".utf8))let fetched = Date(timeIntervalSince1970: 1_792_315_250)@@ -206,6 +206,9 @@ struct HomebrewTests {#expect(check(false) == confirmed)#expect(check(true) == fetched)+ let older = fetched.addingTimeInterval(-6 * 24 * 60 * 60)+ try date(older, packages)+ #expect(check(false) == older, "a fetch of Homebrew's own code that left its definitions as they were")let pinned = Calendar(identifier: .gregorian).date(from: DateComponents(year: 1970, month: 1, day: 1))try date(try #require(pinned), packages)#expect(check(false) == fetched, "a download Homebrew couldn't verify")@@ -229,7 +232,6 @@ struct HomebrewTests {#expect((read == nil) == (fetched == nil && confirmed.isEmpty))if let read {#expect(([fetched] + confirmed).compactMap(\.self).contains { abs(read.timeIntervalSince($0)) < 0.001 })- #expect(fetched.map { read >= $0.addingTimeInterval(-0.001) } ?? true)}guard await Homebrew.hasLocalDefinitions() else { return }#expect(try await Homebrew.installedPackages().allSatisfy { $0.lastUpdateCheck == read })