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 GitHub every day whether a new version of Peel is out
Țugui Dragoș6e94bd7e1af1
diff --git a/Packages/PeelCore/Sources/PeelCore/Updates/UpdateSchedule.swift b/Packages/PeelCore/Sources/PeelCore/Updates/UpdateSchedule.swiftindex d79bfd6f..a5a4c6df 100644--- a/Packages/PeelCore/Sources/PeelCore/Updates/UpdateSchedule.swift+++ b/Packages/PeelCore/Sources/PeelCore/Updates/UpdateSchedule.swift@@ -1,10 +1,12 @@public import Foundation+internal import PeelPrivileged/// When to check an app for updates again.////// Most apps answer "up to date" for months, and each answer costs a request to someone else's server. So/// every answer that changes nothing doubles the wait, up to a week. A found update sets the wait back to a-/// day, because one release is often followed by another.+/// day, because one release is often followed by another. Peel's own releases wait a day at most+/// (`longestWait(for:)`).////// A feed that fails keeps a separate count, from 6 hours up to 2 days, since a server that is down may be/// back soon. A long healthy wait says nothing about when a broken server recovers, so the counts stay apart.@@ -30,7 +32,8 @@ public struct UpdateSchedule: Sendable, Equatable, Codable {public static func next(after status: UpdateStatus,following previous: UpdateSchedule? = nil,- from now: Date = .now+ from now: Date = .now,+ longest: TimeInterval = UpdateSchedule.longest) -> UpdateSchedule {// An "up to date" found before the app was due (Rescan, or a bundle that changed) says nothing about how// often the app ships, so the wait stays the same and only restarts from `now`.@@ -42,7 +45,7 @@ public struct UpdateSchedule: Sendable, Equatable, Codable {healthyWait: nil)}- let wait = wait(after: status, following: previous)+ let wait = wait(after: status, following: previous, longest: longest)return UpdateSchedule(wait: wait,due: now.addingTimeInterval(wait),@@ -51,14 +54,18 @@ public struct UpdateSchedule: Sendable, Equatable, Codable {)}- private static func wait(after status: UpdateStatus, following previous: UpdateSchedule?) -> TimeInterval {+ private static func wait(+ after status: UpdateStatus,+ following previous: UpdateSchedule?,+ longest: TimeInterval+ ) -> TimeInterval {switch status {case .updateAvailable:basecase .upToDate:min(max(healthyWait(before: previous), base) * 2, longest)case .failed:- min(max(failingWait(before: previous) * 2, afterFailure), longestAfterFailure)+ min(max(failingWait(before: previous) * 2, afterFailure), longestAfterFailure, longest)case .unsupported:// Nowhere to ask. What would change the answer is the app being replaced, and a bundle that// changes is checked at once whatever the wait says.@@ -66,6 +73,12 @@ public struct UpdateSchedule: Sendable, Equatable, Codable {}}+ /// The longest wait for `app`. Peel never installs itself, so asking GitHub once a day about its own+ /// releases is how a person learns their copy is out of date.+ public static func longestWait(for app: InstalledApp) -> TimeInterval {+ app.bundleIdentifier?.lowercased() == HelperIdentity.appIdentifier.lowercased() ? base : longest+ }+/// Whether the app is due at `moment`. A due date further away than the wait can only come from a clock/// that was set back since, so it counts as due. Otherwise a check made with the clock a year ahead would/// silence every app for a year.diff --git a/Packages/PeelCore/Tests/PeelCoreTests/UpdateScheduleTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/UpdateScheduleTests.swiftindex abb3cd5f..ce4d450d 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/UpdateScheduleTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/UpdateScheduleTests.swift@@ -40,6 +40,29 @@ struct UpdateScheduleTests {#expect(first.isRetrying)}+ @Test("Peel's own releases are asked about every day, whatever each answer says")+ func peelsOwnReleasesAreAskedAboutEveryDay() {+ let peel = InstalledApp(+ url: URL(filePath: "/Applications/Peel.app", directoryHint: .isDirectory),+ bundleIdentifier: "com.tuguidragos.Peel", name: "Peel"+ )+ let editor = InstalledApp(+ url: URL(filePath: "/Applications/Editor.app", directoryHint: .isDirectory),+ bundleIdentifier: "org.example.editor", name: "Editor"+ )+ let longest = UpdateSchedule.longestWait(for: peel)+ var schedule = UpdateSchedule.next(after: .upToDate, from: moment, longest: longest)+ var waits = [schedule.wait]+ for status in [UpdateStatus.upToDate, .upToDate, .failed, .failed, .failed, .failed, .upToDate] {+ schedule = UpdateSchedule.next(after: status, following: schedule, from: schedule.due, longest: longest)+ waits.append(schedule.wait)+ }++ #expect(waits.allSatisfy { $0 <= UpdateSchedule.base })+ #expect(schedule.wait == UpdateSchedule.base)+ #expect(UpdateSchedule.longestWait(for: editor) == UpdateSchedule.longest)+ }+@Test("Failures double up to two days and stay there, rather than starting over at the ceiling")func theRetryCeilingHolds() {var schedule = UpdateSchedule.next(after: .failed, from: moment)diff --git a/Peel/Model/AppLibrary.swift b/Peel/Model/AppLibrary.swiftindex f4bf76ae..b6cf52ad 100644--- a/Peel/Model/AppLibrary.swift+++ b/Peel/Model/AppLibrary.swift@@ -561,7 +561,11 @@ final class AppLibrary {guard let identifier = app.bundleIdentifier else { continue }memory[identifier] = UpdateMemory(status: kept,- schedule: UpdateSchedule.next(after: status, following: memory[identifier]?.schedule),+ schedule: UpdateSchedule.next(+ after: status,+ following: memory[identifier]?.schedule,+ longest: UpdateSchedule.longestWait(for: app)+ ),checked: status == .failed ? memory[identifier]?.checked : .now,describing: app,developer: answer.developer ?? memory[identifier]?.developerdiff --git a/README.md b/README.mdindex 1db0c768..24c7491a 100644--- a/README.md+++ b/README.md@@ -57,8 +57,9 @@ brew install --cask tuguidragos/tap/peelHomebrew also puts the `peel` command on your path.To update Peel, download the new release and replace the copy in your Applications folder, or run-`brew upgrade --cask peel`. About Peel says when a new version is out, with a Download button, or-the Homebrew command for a copy Homebrew installed, and downloads nothing itself.+`brew upgrade --cask peel`. Peel asks GitHub once a day whether a new version is out, while update checks are on,+and About Peel then says so, with a Download button, or the Homebrew command for a copy Homebrew installed,+and downloads nothing itself.## What Peel does