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
Ask again about an app Peel couldn't check before it learned how
Țugui Dragoș017da808a1ca
diff --git a/Packages/PeelCore/Sources/PeelCore/Updates/UpdateChecker.swift b/Packages/PeelCore/Sources/PeelCore/Updates/UpdateChecker.swiftindex 20beb26b..1617a4b1 100644--- a/Packages/PeelCore/Sources/PeelCore/Updates/UpdateChecker.swift+++ b/Packages/PeelCore/Sources/PeelCore/Updates/UpdateChecker.swift@@ -1,6 +1,10 @@public import Foundationpublic struct UpdateChecker: Sendable {+ /// Raised whenever the checker learns to answer for apps it couldn't check before, so that the answer it gave+ /// them is asked again rather than waited out (`UpdateMemory.recalled`).+ public static let revision = 2+/// The largest reply read. An update feed is a small XML, YAML, or JSON file, and its address comes from/// the app's own bundle, so the server is not trusted to keep its reply small.private static let maximumFeedBytes = 4 * 1_024 * 1_024diff --git a/Packages/PeelCore/Sources/PeelCore/Updates/UpdateMemory.swift b/Packages/PeelCore/Sources/PeelCore/Updates/UpdateMemory.swiftindex 54cce8e1..b9ea369a 100644--- a/Packages/PeelCore/Sources/PeelCore/Updates/UpdateMemory.swift+++ b/Packages/PeelCore/Sources/PeelCore/Updates/UpdateMemory.swift@@ -16,6 +16,8 @@ public struct UpdateMemory: Codable, Equatable, Sendable {/// The developer's name from the App Store. It is saved because an App Store app's signature is Apple's and/// does not name the developer, and the next check may be a week away.public let developer: String?+ /// The `UpdateChecker.revision` that gave the answer; nil for one saved before revisions were kept.+ public let revision: Int?public init(status: UpdateStatus,@@ -30,6 +32,7 @@ public struct UpdateMemory: Codable, Equatable, Sendable {self.developer = developerversion = app.versionbuildVersion = app.buildVersion+ revision = UpdateChecker.revision}public func describes(_ app: InstalledApp) -> Bool {@@ -41,8 +44,9 @@ public struct UpdateMemory: Codable, Equatable, Sendable {static let longestAbsence: TimeInterval = 90 * 24 * 60 * 60/// Returns the entries that still apply to `apps`. An entry is dropped when no installed copy is the build it- /// describes, which also makes that app due at once, or when the app is not installed and the entry is more- /// than `longestAbsence` past due. With two copies at two builds, the entry describes one of them and stays.+ /// describes, which also makes that app due at once, when an earlier checker couldn't check the app, or when+ /// the app is not installed and the entry is more than `longestAbsence` past due. With two copies at two+ /// builds, the entry describes one of them and stays.public static func recalled(from memory: [String: UpdateMemory],for apps: [InstalledApp],@@ -50,6 +54,7 @@ public struct UpdateMemory: Codable, Equatable, Sendable {) -> [String: UpdateMemory] {let installed = InstalledApp.byIdentifier(apps)return memory.filter { identifier, entry in+ if entry.status == .unsupported, entry.revision ?? 1 < UpdateChecker.revision { return false }guard let copies = installed[identifier] else {return entry.schedule.due.addingTimeInterval(longestAbsence) > now}diff --git a/Packages/PeelCore/Tests/PeelCoreTests/UpdateMemoryTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/UpdateMemoryTests.swiftindex a37e2c7b..30661c52 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/UpdateMemoryTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/UpdateMemoryTests.swift@@ -63,6 +63,23 @@ struct UpdateMemoryTests {)}+ @Test func asksAgainAboutAnAppAnEarlierCheckerCouldNotCheck() throws {+ let saved = Data(#"{"com.example.foo":{"status":{"unsupported":{}},"schedule":{"due":814968811,"isRetrying":false,"wait":604800},"checked":814364011,"version":"1.0","buildVersion":"1"}}"#.utf8)+ let earlier = try JSONDecoder().decode([String: UpdateMemory].self, from: saved)+ let now = Date(timeIntervalSinceReferenceDate: 814364011)++ #expect(UpdateMemory.recalled(from: earlier, for: [app("1.0")], now: now).isEmpty)++ let current = ["com.example.foo": UpdateMemory(status: .unsupported, schedule: schedule, checked: now, describing: app("1.0"))]+ #expect(UpdateMemory.recalled(from: current, for: [app("1.0")], now: now) == current)++ let upToDate = try JSONDecoder().decode(+ [String: UpdateMemory].self,+ from: Data(String(decoding: saved, as: UTF8.self).replacingOccurrences(of: "unsupported", with: "upToDate").utf8)+ )+ #expect(UpdateMemory.recalled(from: upToDate, for: [app("1.0")], now: now) == upToDate)+ }+/// An entry stored by an earlier version of Peel names no build, so it describes no app, and the app is/// checked again.@Test func readsAnEntryStoredBeforeBuildsWereKept() throws {