Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

Show how old an Up to date is, and let it go when nothing renews it

Țugui Dragoșc64f9c4ff9a0
diff --git a/GUIDE.md b/GUIDE.md
index 16671de5..0e8886bc 100644
--- a/GUIDE.md
+++ b/GUIDE.md
@@ -83,7 +83,7 @@ and how to get it, [SAFETY.md](SAFETY.md) what it protects, [PRIVACY.md](PRIVACY
check for updates too, unless the app names a feed. Rescan in Applications asks about every app again at once. Skip
This Version and Never Check This App keep it quiet about the ones you want left alone, and Settings > General lists
them under Muted Updates, where Check Again brings their updates back. Turning off Check for app updates there stops
- the checks.
+ the checks, and an app's Up to date, which Peel then no longer renews, goes after a week.
## Free up disk space
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index e966c9f1..a9da96c2 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -119610,6 +119610,112 @@
}
}
},
+ "Peel last checked %@." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel to naposledy zkontroloval %@."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel hat zuletzt %@ geprüft."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel lo comprobó por última vez %@."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel a vérifié pour la dernière fois %@."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Ultima verifica di Peel: %@."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peelが最後に確認したのは%@です。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel이 %@ 마지막으로 확인했습니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel heeft %@ voor het laatst gecontroleerd."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel ostatnio sprawdzał %@."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "O Peel verificou pela última vez %@."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel a verificat ultima dată %@."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel в последний раз проверял обновления %@."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel kontrollerade senast %@."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel en son %@ denetledi."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel востаннє перевіряла %@."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel上次检查是在%@。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel上次檢查是在%@。"
+ }
+ }
+ }
+ },
"Peel last saw %@ installed %@" : {
"localizations" : {
"cs" : {
diff --git a/Packages/PeelCore/Sources/PeelCore/Updates/UpdateChecker.swift b/Packages/PeelCore/Sources/PeelCore/Updates/UpdateChecker.swift
index a6e9e4d4..401bb513 100644
--- a/Packages/PeelCore/Sources/PeelCore/Updates/UpdateChecker.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Updates/UpdateChecker.swift
@@ -185,6 +185,12 @@ public struct UpdateChecker: Sendable {
return !VersionComparison.isNewer(tap, than: version)
}
+ /// Whether an answer that came at `checked` may still be shown as true while nothing asks again: for
+ /// `UpdateSchedule.longest`, the longest wait between two checks. An answer of unknown date doesn't hold.
+ public func stillHolds(answeredAt checked: Date?) -> Bool {
+ checked.map { clock().timeIntervalSince($0) <= UpdateSchedule.longest } ?? false
+ }
+
/// The cask `app` came from, and why Homebrew can't tell, when only Homebrew could say whether the app is up to
/// date and it has no answer (`homebrewStatus(of:appVersion:at:)`), so a check has none for the app.
public func homebrewCannotTell(
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/UpdateCheckerTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/UpdateCheckerTests.swift
index 09fcba66..f71fca00 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/UpdateCheckerTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/UpdateCheckerTests.swift
@@ -357,6 +357,13 @@ private final class OfflineProtocol: URLProtocol, @unchecked Sendable {
#expect(notChecked?.reason == .notCheckedRecently)
}
+ @Test func anAnswerHoldsForTheLongestWaitBetweenTwoChecks() {
+ let day: TimeInterval = 24 * 60 * 60
+ #expect(checking(at: homebrewChecked + 6 * day).stillHolds(answeredAt: homebrewChecked))
+ #expect(!checking(at: homebrewChecked + 8 * day).stillHolds(answeredAt: homebrewChecked))
+ #expect(!checking(at: homebrewChecked).stillHolds(answeredAt: nil))
+ }
+
@Test func takesNoUpToDateFromHomebrewWhereItComparesNoVersion() {
let recent = checking(at: homebrewChecked + 60 * 60)
let newest = HomebrewPackage(
diff --git a/Peel/Model/AppLibrary.swift b/Peel/Model/AppLibrary.swift
index c92062f5..3a040dd4 100644
--- a/Peel/Model/AppLibrary.swift
+++ b/Peel/Model/AppLibrary.swift
@@ -709,7 +709,15 @@ final class AppLibrary {
/// The answer about `app`'s updates that its page shows: an update the user muted is not announced again.
func shownUpdateStatus(of app: InstalledApp) -> UpdateStatus? {
- app.isPeelItself ? nil : updatePreferences.shownStatus(updateStatuses[app.id], for: app)
+ guard !app.isPeelItself else { return nil }
+ let shown = updatePreferences.shownStatus(updateStatuses[app.id], for: app)
+ // With the checks off, an "up to date" ages unasked: past the longest wait it says nothing, unless Homebrew
+ // says it now, which counts only for a day after its own check.
+ guard shown == .upToDate, !defaults.isOn(SettingsKey.checksForAppUpdates, whenNeverSet: true),
+ !updateChecker.stillHolds(answeredAt: lastUpdateChecks[app.id]),
+ updateChecker.homebrewStatus(for: app, casks: casks) != .upToDate
+ else { return shown }
+ return nil
}
/// The apps the reading of the folders found, without those shown on the list from elsewhere: what is installed,
diff --git a/Peel/Views/UpdateStatusBadge.swift b/Peel/Views/UpdateStatusBadge.swift
index 586d92ea..15b08542 100644
--- a/Peel/Views/UpdateStatusBadge.swift
+++ b/Peel/Views/UpdateStatusBadge.swift
@@ -34,7 +34,11 @@ struct UpdateStatusBadge: View {
case .updateAvailable:
Badge(title: Text("Update available: \(status.displayVersion ?? "")"), systemImage: "arrow.down.circle", tint: .blue)
case .upToDate:
- Badge(title: Text("Up to date"), systemImage: "checkmark.circle", tint: .green)
+ if let lastCheck {
+ upToDate.help(Text("Peel last checked \(lastCheck, format: .relative(presentation: .named))."))
+ } else {
+ upToDate
+ }
case .unsupported:
NoteBadge(
title: Text("Can’t check for updates"),
@@ -56,6 +60,10 @@ struct UpdateStatusBadge: View {
}
}
+ private var upToDate: some View {
+ Badge(title: Text("Up to date"), systemImage: "checkmark.circle", tint: .green)
+ }
+
/// Why Peel can't check this app. Several reasons share the one badge, so the note says which applies. The
/// preferred update source is never the reason: an app not sold by the App Store is checked through its
/// own feed whatever that setting says.
diff --git a/PeelTests/AppLibraryTests.swift b/PeelTests/AppLibraryTests.swift
index a7dadaa8..20700e2c 100644
--- a/PeelTests/AppLibraryTests.swift
+++ b/PeelTests/AppLibraryTests.swift
@@ -596,6 +596,34 @@ private nonisolated final class TestClock: Sendable {
#expect(library.releaseNotes.asks("org.example.fed", version: "1.1"))
}
+ @Test func anUpToDateNoCheckRenewsSaysNothingAfterTheLongestWait() async throws {
+ let folder = FileManager.default.temporaryDirectory.appending(path: "PeelTests-\(UUID().uuidString)")
+ let bundle = try caskApp("Fed", in: folder, feed: "https://feed.example.com/appcast.xml")
+ defer { try? FileManager.default.removeItem(at: folder) }
+ let made = try MadeUpDefaults()
+ defer { made.forget() }
+ AppcastProtocol.body.withLock {
+ $0 = Data("""
+ <rss xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle"><channel><item>\
+ <enclosure url="https://feed.example.com/u.zip" sparkle:version="100" sparkle:shortVersionString="1.0" />\
+ </item></channel></rss>
+ """.utf8)
+ }
+ let now = Date.now
+ let clock = TestClock(now)
+ let library = library(with: made.defaults, notesIn: folder, clock: clock)
+ #expect(await library.reveal([bundle]))
+ let app = try #require(library.apps.first { $0.bundleIdentifier == "org.example.fed" })
+ await library.checkForUpdates([app], force: true)
+ #expect(library.shownUpdateStatus(of: app) == .upToDate)
+
+ made.defaults.set(false, forKey: SettingsKey.checksForAppUpdates)
+ clock.set(now + 24 * 60 * 60)
+ #expect(library.shownUpdateStatus(of: app) == .upToDate)
+ clock.set(now + 30 * 24 * 60 * 60)
+ #expect(library.shownUpdateStatus(of: app) == nil)
+ }
+
@Test func theRoundRescanStartsSaysWhenItEnds() async throws {
let folder = FileManager.default.temporaryDirectory.appending(path: "PeelTests-\(UUID().uuidString)")
let bundle = try caskApp("Fed", in: folder, feed: "https://feed.example.com/appcast.xml")