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.

Give the right reason when Peel can't check an app

Țugui Dragoș8abea8010d69
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index a9da96c2..4a02a098 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -167483,6 +167483,112 @@
}
}
},
+ "The App Store %@ came from gives Peel no version of it to compare, as for an app that store doesn’t sell anymore. The App Store app itself knows when there is an update." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "App Store, ze kterého aplikace %@ pochází, neudává žádnou její verzi, kterou by Peel dokázal porovnat, jako u aplikace, kterou tento obchod už neprodává. Kdy je k dispozici aktualizace, ví sama aplikace App Store."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Der App Store, aus dem „%@“ stammt, gibt keine Version an, mit der Peel vergleichen kann, etwa bei einer App, die dieser Store nicht mehr verkauft. Die App „App Store“ selbst weiß, wann es ein Update gibt."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "La tienda de App Store de la que viene %@ no indica ninguna versión de la app que Peel pueda comparar, como en el caso de una app que esa tienda ya no vende. La propia app App Store sabe cuándo hay una actualización."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "L’App Store dont provient %@ n’en indique aucune version que Peel puisse comparer, comme c’est le cas pour une app que cette boutique ne vend plus. L’app App Store elle-même sait quand une mise à jour est disponible."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Lo Store da cui proviene %@ non riporta nessuna versione che Peel possa confrontare, come accade per un’app che quello Store non vende più. È l’app App Store a sapere quando c’è un aggiornamento."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "“%@”の入手元のApp Storeは、Peelが比較できるバージョンを示していません。そのストアで販売を終了したアプリの場合と同様です。アップデートがあるかどうかは、App Storeアプリ自体が把握しています。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "‘%@’을(를) 받은 App Store는 Peel이 비교할 수 있는 버전을 알려 주지 않습니다. 해당 스토어에서 더 이상 판매하지 않는 앱의 경우가 그렇습니다. 업데이트가 있는지는 App Store 앱이 알고 있습니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "De App Store waar %@ vandaan komt, vermeldt geen versie die Peel kan vergelijken, zoals bij een app die niet meer in die store wordt verkocht. De App Store-app zelf weet wanneer er een update is."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "App Store, z którego pochodzi aplikacja %@, nie podaje jej wersji, którą Peel mógłby porównać z zainstalowaną, jak w przypadku aplikacji, której ten sklep już nie sprzedaje. Sama aplikacja App Store wie, kiedy jest dostępne uaktualnienie."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "A App Store de onde %@ veio não informa nenhuma versão dele para o Peel comparar, como no caso de um app que essa loja não vende mais. O próprio app App Store sabe quando há uma atualização."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "App Store din care provine %@ nu indică nicio versiune a acesteia pe care Peel să o poată compara, ca în cazul unei aplicații pe care magazinul respectiv nu o mai vinde. Aplicația App Store însăși știe când există o actualizare."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "App Store, из которого получено приложение «%@», не сообщает его версию, которую Peel мог бы сравнить с установленной, как бывает с приложением, которое этот магазин больше не продает. Само приложение App Store знает, когда выходит обновление."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "App Store-affären som %@ kom från anger ingen version av appen som Peel kan jämföra med, till exempel för en app som den affären inte längre säljer. Appen App Store vet själv när det finns en uppdatering."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@ uygulamasının geldiği App Store, o mağazanın artık satmadığı bir uygulama için olduğu gibi, bu uygulama için de Peel’in karşılaştırabileceği bir sürüm vermiyor. Ne zaman güncelleme olduğunu App Store uygulamasının kendisi bilir."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "App Store, з якого отримано програму «%@», не повідомляє версії, яку Peel може порівняти, як буває з програмою, якої цей магазин більше не продає. Про наявність оновлення знає сама програма App Store."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "“%@”所来自的App Store没有给出它的版本号供Peel比较,例如该商店已不再销售的App就是如此。App Store App本身知道何时有更新。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "「%@」的來源App Store沒有提供Peel能比對的版本,就像對於該商店已不再販售的App一樣。App Store App本身才知道何時有更新。"
+ }
+ }
+ }
+ },
"The App Store gives Peel no version of %@ to compare, as for an app it doesn’t sell in your Mac’s region or doesn’t sell anymore. The App Store app itself knows when there is an update." : {
"localizations" : {
"cs" : {
diff --git a/Packages/PeelCore/Sources/PeelCore/Updates/UpdateChecker.swift b/Packages/PeelCore/Sources/PeelCore/Updates/UpdateChecker.swift
index 401bb513..2020a804 100644
--- a/Packages/PeelCore/Sources/PeelCore/Updates/UpdateChecker.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Updates/UpdateChecker.swift
@@ -185,6 +185,25 @@ public struct UpdateChecker: Sendable {
return !VersionComparison.isNewer(tap, than: version)
}
+ /// Why Peel can't check `app`, for an app a check answered `.unsupported`.
+ public func whyItCannotCheck(
+ _ app: InstalledApp, preference: UpdateSource, casks: [HomebrewPackage]
+ ) -> CannotCheck {
+ if let silence = homebrewCannotTell(about: app, preference: preference, casks: casks) {
+ return .homebrewCannotTell(silence)
+ }
+ if app.isSystemProtected { return .cameWithMacOS }
+ if app.isFromSetapp { return .cameFromSetapp }
+ if app.version == nil { return .namesNoVersion }
+ if app.isFromAppStore {
+ guard case .appStore(.iPhoneAndiPad(_, let store?)) = app.updateFeed else {
+ return .notInTheAppStore(store: nil)
+ }
+ return .notInTheAppStore(store: store)
+ }
+ return .namesNoFeed
+ }
+
/// 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 {
@@ -495,6 +514,20 @@ public struct UpdateAnswer: Sendable, Hashable {
}
}
+/// Why Peel can't check an app for updates, which the note behind Can't check for updates says in words.
+public enum CannotCheck: Sendable, Hashable {
+ case homebrewCannotTell(HomebrewCannotTell)
+ /// It came with macOS, which Software Update keeps current.
+ case cameWithMacOS
+ /// It came from Setapp, which keeps it current.
+ case cameFromSetapp
+ case namesNoVersion
+ /// The App Store gave no version to compare: it doesn't sell the app in `store`, the country of the store an
+ /// iPhone or iPad app came from, or, when nil, in this Mac's region.
+ case notInTheAppStore(store: String?)
+ case namesNoFeed
+}
+
/// Why Homebrew, which installed an app nobody else can answer for, can't say whether the app is up to date.
public struct HomebrewCannotTell: Sendable, Hashable {
public enum Reason: Sendable, Hashable {
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/UpdateCheckerTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/UpdateCheckerTests.swift
index f71fca00..5345e610 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/UpdateCheckerTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/UpdateCheckerTests.swift
@@ -357,6 +357,30 @@ private final class OfflineProtocol: URLProtocol, @unchecked Sendable {
#expect(notChecked?.reason == .notCheckedRecently)
}
+ @Test func saysWhyItCanNotCheckAnApp() {
+ let checker = checking(at: homebrewChecked)
+ let iPad = InstalledApp(
+ url: URL(filePath: "/Applications/Board.app"), bundleIdentifier: "org.example.board", name: "Board",
+ version: "1.0", isFromAppStore: true, updateFeed: .appStore(.iPhoneAndiPad(item: 1, store: "de"))
+ )
+ let mac = InstalledApp(
+ url: URL(filePath: "/Applications/Notes Pro.app"), bundleIdentifier: "org.example.notes", name: "Notes Pro",
+ version: "1.0", isFromAppStore: true, updateFeed: .appStore(.mac)
+ )
+ let unversioned = InstalledApp(
+ url: URL(filePath: "/Applications/Tool.app"), bundleIdentifier: "org.example.tool", name: "Tool"
+ )
+
+ #expect(checker.whyItCannotCheck(iPad, preference: .automatic, casks: []) == .notInTheAppStore(store: "de"))
+ #expect(checker.whyItCannotCheck(mac, preference: .automatic, casks: []) == .notInTheAppStore(store: nil))
+ #expect(checker.whyItCannotCheck(feedlessApp, preference: .automatic, casks: []) == .namesNoFeed)
+ #expect(checker.whyItCannotCheck(unversioned, preference: .automatic, casks: []) == .namesNoVersion)
+ let stale = checking(at: homebrewChecked + 2 * Homebrew.autoUpdateInterval)
+ let current = cask(checked: homebrewChecked)
+ let reason = stale.whyItCannotCheck(feedlessApp, preference: .automatic, casks: [current])
+ #expect(reason == .homebrewCannotTell(HomebrewCannotTell(cask: current, reason: .notCheckedRecently)))
+ }
+
@Test func anAnswerHoldsForTheLongestWaitBetweenTwoChecks() {
let day: TimeInterval = 24 * 60 * 60
#expect(checking(at: homebrewChecked + 6 * day).stillHolds(answeredAt: homebrewChecked))
diff --git a/Peel/Model/AppLibrary.swift b/Peel/Model/AppLibrary.swift
index 3a040dd4..ff8a264e 100644
--- a/Peel/Model/AppLibrary.swift
+++ b/Peel/Model/AppLibrary.swift
@@ -438,8 +438,8 @@ final class AppLibrary {
homebrewApps[app.id]
}
- func homebrewCannotTell(about app: InstalledApp) -> HomebrewCannotTell? {
- updateChecker.homebrewCannotTell(about: app, preference: updateSource, casks: casks)
+ func whyItCannotCheck(_ app: InstalledApp) -> CannotCheck {
+ updateChecker.whyItCannotCheck(app, preference: updateSource, casks: casks)
}
func isUnused(_ app: InstalledApp) -> Bool {
@@ -709,7 +709,8 @@ 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? {
- guard !app.isPeelItself else { return nil }
+ // A web app updates with its website, so there is nothing to check, and nothing is said.
+ guard !app.isPeelItself, app.webApp == nil 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.
@@ -863,9 +864,9 @@ final class AppLibrary {
}
/// Whether update checks ask about `app`. Never about Peel's own copies, which Sparkle keeps current, checking
- /// the one running, nor about an app the user told Peel never to check or a copy in a Trash.
+ /// the one running, nor about a web app, nor an app the user told Peel never to check or a copy in a Trash.
private func isAskedAboutUpdates(_ app: InstalledApp) -> Bool {
- !app.isPeelItself && !isIgnored(app) && !appsInATrash.contains(app.id)
+ !app.isPeelItself && app.webApp == nil && !isIgnored(app) && !appsInATrash.contains(app.id)
}
private func matchHomebrewApps() {
diff --git a/Peel/Views/AppHeader.swift b/Peel/Views/AppHeader.swift
index 87590838..10569bf8 100644
--- a/Peel/Views/AppHeader.swift
+++ b/Peel/Views/AppHeader.swift
@@ -12,7 +12,7 @@ struct AppHeader<Actions: View>: View {
/// The version a waiting update would bring. The caller passes it only when `AppLibrary.hasUpdate` is true.
var waitingVersion: String?
var lastCheck: Date?
- var homebrewCannotTell: HomebrewCannotTell?
+ let cannotCheck: CannotCheck
var total: SizeTotal?
/// True when the app frees much less than its size, because most of it is shared with another copy.
var sharesStorage = false
@@ -103,7 +103,7 @@ struct AppHeader<Actions: View>: View {
status: updateStatus,
isChecking: isCheckingForUpdates,
lastCheck: lastCheck,
- homebrewCannotTell: homebrewCannotTell
+ cannotCheck: cannotCheck
)
}
}
diff --git a/Peel/Views/AppPageHeader.swift b/Peel/Views/AppPageHeader.swift
index d894238d..4f08693f 100644
--- a/Peel/Views/AppPageHeader.swift
+++ b/Peel/Views/AppPageHeader.swift
@@ -22,7 +22,7 @@ struct AppPageHeader: View {
isCheckingForUpdates: library.appsCheckingForUpdates.contains(plan.app.id),
waitingVersion: waitingVersion == nil ? nil : library.updateStatuses[plan.app.id]?.displayVersion,
lastCheck: library.lastUpdateChecks[plan.app.id],
- homebrewCannotTell: library.homebrewCannotTell(about: plan.app),
+ cannotCheck: library.whyItCannotCheck(plan.app),
total: plan.total,
sharesStorage: plan.appSharesStorage
) {
diff --git a/Peel/Views/Intel/IntelDetailView.swift b/Peel/Views/Intel/IntelDetailView.swift
index d86b95d1..14dee8ab 100644
--- a/Peel/Views/Intel/IntelDetailView.swift
+++ b/Peel/Views/Intel/IntelDetailView.swift
@@ -80,7 +80,7 @@ struct IntelDetailView: View {
app: app,
status: status,
isChecking: library.appsCheckingForUpdates.contains(app.id),
- homebrewCannotTell: library.homebrewCannotTell(about: app)
+ cannotCheck: library.whyItCannotCheck(app)
)
}
}
diff --git a/Peel/Views/UpdateStatusBadge.swift b/Peel/Views/UpdateStatusBadge.swift
index 15b08542..40054ad7 100644
--- a/Peel/Views/UpdateStatusBadge.swift
+++ b/Peel/Views/UpdateStatusBadge.swift
@@ -7,7 +7,7 @@ struct UpdateStatusBadge: View {
let isChecking: Bool
/// When a check last got an answer, which is what the note for a failed check tells the user.
var lastCheck: Date?
- var homebrewCannotTell: HomebrewCannotTell?
+ let cannotCheck: CannotCheck
var body: some View {
BusyShown(isBusy: isChecking) { isShown in
@@ -68,10 +68,11 @@ struct UpdateStatusBadge: View {
/// 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.
private var unsupportedReason: Text {
- if let homebrewCannotTell {
- switch homebrewCannotTell.reason {
+ switch cannotCheck {
+ case .homebrewCannotTell(let silence):
+ switch silence.reason {
case .notCheckedRecently:
- if let checked = homebrewCannotTell.cask.lastUpdateCheck {
+ if let checked = silence.cask.lastUpdateCheck {
Text("Only Homebrew can say whether \(app.name) is up to date, and Homebrew last checked for new versions \(checked, format: .relative(presentation: .named)). Peel counts what Homebrew says only for a day after it checks. Update Homebrew on the Homebrew page, or run `brew update` in Terminal, and Peel can tell again.")
} else {
Text("Only Homebrew can say whether \(app.name) is up to date, but Peel can’t tell when Homebrew last checked for new versions, so it doesn’t count what Homebrew says.")
@@ -81,15 +82,17 @@ struct UpdateStatusBadge: View {
case .leftToTheApp:
Text("Only Homebrew could say whether \(app.name) is up to date, but Homebrew’s settings leave apps that update themselves to their own updates, so it doesn’t compare their versions. Look for an update inside the app.")
}
- } else if app.isSystemProtected {
+ case .cameWithMacOS:
Text("\(app.name) came with macOS. Software Update is what keeps it current, so Peel has nothing to ask.")
- } else if app.isFromSetapp {
+ case .cameFromSetapp:
Text("\(app.name) came from Setapp. Setapp is what keeps it current, so Peel has nothing to ask.")
- } else if app.version == nil {
+ case .namesNoVersion:
Text("\(app.name) doesn’t say which version it is, so Peel has nothing to compare an update with. Look for an update inside the app.")
- } else if app.isFromAppStore {
+ case .notInTheAppStore(store: nil):
Text("The App Store gives Peel no version of \(app.name) to compare, as for an app it doesn’t sell in your Mac’s region or doesn’t sell anymore. The App Store app itself knows when there is an update.")
- } else {
+ case .notInTheAppStore:
+ Text("The App Store \(app.name) came from gives Peel no version of it to compare, as for an app that store doesn’t sell anymore. The App Store app itself knows when there is an update.")
+ case .namesNoFeed:
Text("\(app.name) doesn’t say where it updates from in a way Peel can read. Peel reads an app’s update feed from the app’s own files, and asking Apple about every app instead would send Apple a list of what is installed on this Mac. Look for an update inside the app.")
}
}
diff --git a/PeelTests/AppLibraryTests.swift b/PeelTests/AppLibraryTests.swift
index 20700e2c..fd212607 100644
--- a/PeelTests/AppLibraryTests.swift
+++ b/PeelTests/AppLibraryTests.swift
@@ -765,7 +765,38 @@ private nonisolated final class TestClock: Sendable {
library.loadHomebrewCasks([newest], knowsItsOwnApps: true)
#expect(library.shownUpdateStatus(of: app) == .unsupported)
- #expect(library.homebrewCannotTell(about: app)?.reason == .installsTheNewest)
+ guard case .homebrewCannotTell(let silence) = library.whyItCannotCheck(app) else {
+ Issue.record("Homebrew is the reason")
+ return
+ }
+ #expect(silence.reason == .installsTheNewest)
+ }
+
+ @Test func aWebAppIsNotCheckedForUpdates() async throws {
+ let folder = FileManager.default.temporaryDirectory.appending(path: "PeelTests-\(UUID().uuidString)")
+ let bundle = folder.appending(path: "Wiki.app", directoryHint: .isDirectory)
+ try FileManager.default.createDirectory(
+ at: bundle.appending(path: "Contents"), withIntermediateDirectories: true
+ )
+ let info: [String: Any] = [
+ "CFBundleIdentifier": "org.example.Browser.app.wiki", "CFBundleName": "Wiki",
+ "CFBundlePackageType": "APPL", "CFBundleShortVersionString": "1.0", "CFBundleVersion": "1",
+ "CrBundleIdentifier": "org.example.Browser", "CrAppModeShortcutID": "wiki",
+ ]
+ try PropertyListSerialization.data(fromPropertyList: info, format: .xml, options: 0)
+ .write(to: bundle.appending(path: "Contents/Info.plist"))
+ defer { try? FileManager.default.removeItem(at: folder) }
+ let made = try MadeUpDefaults()
+ defer { made.forget() }
+ let library = library(with: made.defaults, notesIn: folder)
+ #expect(await library.reveal([bundle]))
+ let app = try #require(library.apps.first { $0.bundleIdentifier == "org.example.Browser.app.wiki" })
+ #expect(app.webApp == .browser(identifier: "org.example.Browser"))
+
+ await library.checkForUpdates([app], force: true)
+
+ #expect(library.updateStatuses[app.id] == nil)
+ #expect(library.shownUpdateStatus(of: app) == nil)
}
@Test func anAppPeelNeverChecksGetsNothingFromHomebrew() async throws {