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
An app that names no version never shows a false update
Țugui Dragoș3d6fc302119c
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstringsindex 4924e536..039049fa 100644--- a/Localization/Peel/Localizable.xcstrings+++ b/Localization/Peel/Localizable.xcstrings@@ -751,6 +751,112 @@}}},+ "%@ doesn’t say which version it is, so Peel has nothing to compare an update with. Look for an update inside the app." : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Aplikace %@ neuvádí, o jakou verzi jde, takže Peel nemá s čím aktualizaci porovnat. Aktualizaci hledejte přímo v aplikaci."+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "„%@“ gibt nicht an, um welche Version es sich handelt, daher hat Peel nichts, womit es ein Update vergleichen kann. Suche in der App selbst nach einem Update."+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%@ no indica qué versión es, así que Peel no tiene nada con lo que comparar una actualización. Busca actualizaciones dentro de la app."+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%@ n’indique pas de quelle version il s’agit : Peel n’a donc rien à quoi comparer une mise à jour. Cherchez une mise à jour dans l’app elle-même."+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%@ non indica di quale versione si tratti, quindi Peel non ha nulla con cui confrontare un aggiornamento. Cerca un aggiornamento dall’interno dell’app."+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "“%@”は自身のバージョンを示していないため、Peelにはアップデートと比較するものがありません。アプリ内でアップデートを探してください。"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "‘%@’은(는) 어떤 버전인지 알려 주지 않으므로 Peel이 업데이트와 비교할 것이 없습니다. 앱 안에서 업데이트를 찾아보십시오."+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%@ geeft niet aan welke versie het is, dus Peel heeft niets om een update mee te vergelijken. Zoek in de app zelf naar een update."+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Aplikacja %@ nie podaje, którą ma wersję, więc Peel nie ma z czym porównać uaktualnienia. Poszukaj uaktualnienia w samej aplikacji."+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%@ não informa a própria versão, então o Peel não tem nada com que comparar uma atualização. Procure uma atualização dentro do app."+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Aplicația %@ nu indică ce versiune are, așa că Peel nu are cu ce compara o actualizare. Căutați o actualizare din interiorul aplicației."+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Приложение «%@» не сообщает, какая у него версия, поэтому Peel не с чем сравнить обновление. Поищите обновление в самом приложении."+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%@ anger inte vilken version den har, så Peel har inget att jämföra en uppdatering med. Leta efter en uppdatering inuti appen."+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%@, hangi sürüm olduğunu söylemiyor, bu yüzden Peel’in bir güncellemeyle karşılaştıracak bir şeyi yok. Güncellemeyi uygulamanın içinde arayın."+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Програма «%@» не вказує, яка в неї версія, тож Peel нема з чим порівнювати оновлення. Пошукайте оновлення в самій програмі."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "“%@”没有说明它是哪个版本,因此Peel没有可与更新比较的版本。请在App内查找更新。"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "「%@」沒有說明它是哪個版本,因此Peel無從比對更新。請在App內尋找更新。"+ }+ }+ }+ },"%@ has an update" : {"localizations" : {"cs" : {diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Commands/AppCommands.swift b/Packages/PeelCore/Sources/PeelCommandLine/Commands/AppCommands.swiftindex c9d80d25..27518f99 100644--- a/Packages/PeelCore/Sources/PeelCommandLine/Commands/AppCommands.swift+++ b/Packages/PeelCore/Sources/PeelCommandLine/Commands/AppCommands.swift@@ -607,11 +607,11 @@ struct UpdatesCommand: AsyncParsableCommand {}}- private static func summary(_ status: UpdateStatus) -> String {+ static func summary(_ status: UpdateStatus) -> String {switch status {case .updateAvailable(let version, _, _): "\(version) available"case .upToDate: "up to date"- case .unsupported: "no update feed"+ case .unsupported: "can't check"case .failed: "check failed"}}diff --git a/Packages/PeelCore/Sources/PeelCore/Updates/UpdateChecker.swift b/Packages/PeelCore/Sources/PeelCore/Updates/UpdateChecker.swiftindex aa512f62..41a2acc0 100644--- a/Packages/PeelCore/Sources/PeelCore/Updates/UpdateChecker.swift+++ b/Packages/PeelCore/Sources/PeelCore/Updates/UpdateChecker.swift@@ -86,16 +86,18 @@ public struct UpdateChecker: Sendable {}private func feedAnswer(for app: InstalledApp) async -> UpdateAnswer {- switch app.updateFeed {+ // An app whose bundle names no version has nothing to compare a release with, so nobody is asked.+ guard let installed = app.version else { return UpdateAnswer(status: .unsupported) }+ return switch app.updateFeed {case nil: UpdateAnswer(status: .unsupported)- case .sparkle(let url): UpdateAnswer(status: await sparkleStatus(for: app, at: url))- case .electron(let url): UpdateAnswer(status: await electronStatus(for: app, at: url))- case .gitHubRelease(let url): UpdateAnswer(status: await gitHubReleaseStatus(for: app, at: url))+ case .sparkle(let url): UpdateAnswer(status: await sparkleStatus(for: app, installed: installed, at: url))+ case .electron(let url): UpdateAnswer(status: await electronStatus(installed: installed, at: url))+ case .gitHubRelease(let url): UpdateAnswer(status: await gitHubReleaseStatus(installed: installed, at: url))case .appStore: await appStoreAnswer(for: app)}}- private func sparkleStatus(for app: InstalledApp, at url: URL) async -> UpdateStatus {+ private func sparkleStatus(for app: InstalledApp, installed: String, at url: URL) async -> UpdateStatus {guard let data = await fetch(url) else { return .failed }let item: AppcastItemswitch Appcast.read(data, systemVersion: systemVersion, isAppleSilicon: isAppleSilicon) {@@ -107,24 +109,24 @@ public struct UpdateChecker: Sendable {let isNewer = if let version = item.version, let build = app.buildVersion {VersionComparison.isNewer(version, than: build)} else {- VersionComparison.isNewer(latest, than: app.version ?? "")+ VersionComparison.isNewer(latest, than: installed)}return isNewer ? .updateAvailable(version: latest, source: .developer, releaseNotes: item.releaseNotes) : .upToDate}- private func electronStatus(for app: InstalledApp, at url: URL) async -> UpdateStatus {+ private func electronStatus(installed: String, at url: URL) async -> UpdateStatus {guardlet data = await fetch(url),let latest = ElectronUpdater.version(fromFeed: String(decoding: data, as: UTF8.self))else { return .failed }- return VersionComparison.isNewer(latest, than: app.version ?? "")+ return VersionComparison.isNewer(latest, than: installed)? .updateAvailable(version: latest, source: .developer, releaseNotes: nil): .upToDate}- private func gitHubReleaseStatus(for app: InstalledApp, at url: URL) async -> UpdateStatus {+ private func gitHubReleaseStatus(installed: String, at url: URL) async -> UpdateStatus {guard let data = await fetch(url), let release = GitHubRelease.latest(in: data) else { return .failed }- return VersionComparison.isNewer(release.version, than: app.version ?? "")+ return VersionComparison.isNewer(release.version, than: installed)? .updateAvailable(version: release.version, source: .developer, releaseNotes: release.page): .upToDate}@@ -132,7 +134,7 @@ public struct UpdateChecker: Sendable {/// Asks the App Store about `app`, but only when the app has an App Store receipt, whoever calls this./// Asking about other apps would send Apple, one identifier at a time, the list of installed apps.private func appStoreAnswer(for app: InstalledApp) async -> UpdateAnswer {- guard app.isFromAppStore else { return UpdateAnswer(status: .unsupported) }+ guard app.isFromAppStore, let installed = app.version else { return UpdateAnswer(status: .unsupported) }var reply = await lookup(app.bundleIdentifier, in: country)// A two-letter region with no store, such as Antarctica (AQ), is also refused with HTTP 400.if reply.status == 400, country != "us" {@@ -145,7 +147,7 @@ public struct UpdateChecker: Sendable {case .noMacRecord:return UpdateAnswer(status: .unsupported)case .mac(let latest, let page, let developer):- let status: UpdateStatus = VersionComparison.isNewer(latest, than: app.version ?? "")+ let status: UpdateStatus = VersionComparison.isNewer(latest, than: installed)? .updateAvailable(version: latest, source: .appStore, releaseNotes: page): .upToDatereturn UpdateAnswer(status: status, developer: developer)diff --git a/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swiftindex 87fcfce3..621644df 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift@@ -596,6 +596,12 @@ struct CommandLineTests {#expect(!some.nothingAnswered)}+ /// `--all` lists an app Peel can't check as the app does. "No update feed" was wrong for an app that came with+ /// macOS, an App Store app with no Mac version to read, and an app whose bundle names no version.+ @Test func saysAnAppItCannotCheckCannotBeChecked() {+ #expect(UpdatesCommand.summary(.unsupported) == "can't check")+ }+/// The same rule the app follows: an app the user told Peel to leave alone is not checked, and a skipped/// version is not an update waiting.@Test func readsTheSameUpdateSettingsTheAppDoes() {diff --git a/Packages/PeelCore/Tests/PeelCoreTests/UpdateCheckerTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/UpdateCheckerTests.swiftindex b6279916..c9856059 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/UpdateCheckerTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/UpdateCheckerTests.swift@@ -174,4 +174,33 @@ private final class CannedProtocol: URLProtocol, @unchecked Sendable {reply("itunes.apple.com", "<html>")#expect(await checker.status(for: sold) == .failed, "an answer Peel can't read is still a failed check")}++ /// An app whose bundle names no version, neither `CFBundleShortVersionString` nor `CFBundleVersion`, has nothing+ /// to compare a release with. Read as an empty version, any release was newer, forever. It claims no update, and+ /// nobody is asked.+ @Test func anAppThatNamesNoVersionClaimsNoUpdate() async {+ CannedProtocol.replies.withLock {+ $0 = [+ "feed.example.com": .init(body: Data(appcast("<item><sparkle:version>200</sparkle:version><sparkle:shortVersionString>2.0</sparkle:shortVersionString></item>").utf8)),+ "electron.example.com": .init(body: Data("version: 2.0.0\n".utf8)),+ "api.github.com": .init(body: Data(#"{"tag_name":"v2.0","html_url":"https://github.com/example/editor/releases/tag/v2.0"}"#.utf8)),+ "itunes.apple.com": .init(body: Data(#"{"resultCount":1,"results":[{"kind":"mac-software","version":"2.0","trackViewUrl":"https://apps.apple.com/app/id1"}]}"#.utf8)),+ ]+ }+ CannedProtocol.asked.withLock { $0 = [] }+ let feeds: [UpdateFeed] = [+ .sparkle(URL(string: "https://feed.example.com/appcast.xml")!),+ .electron(URL(string: "https://electron.example.com/latest-mac.yml")!),+ .gitHubRelease(URL(string: "https://api.github.com/repos/example/editor/releases/latest")!),+ .appStore,+ ]+ for feed in feeds {+ let unversioned = InstalledApp(+ url: URL(filePath: "/Applications/Editor.app"), bundleIdentifier: "com.example.editor", name: "Editor",+ isFromAppStore: feed == .appStore, updateFeed: feed+ )+ #expect(await checker.status(for: unversioned) == .unsupported, "\(feed)")+ }+ #expect(CannedProtocol.asked.withLock { $0 }.isEmpty)+ }}diff --git a/Peel/Views/UpdateStatusBadge.swift b/Peel/Views/UpdateStatusBadge.swiftindex 4712b850..23293501 100644--- a/Peel/Views/UpdateStatusBadge.swift+++ b/Peel/Views/UpdateStatusBadge.swift@@ -56,12 +56,14 @@ struct UpdateStatusBadge: View {}}- /// Why Peel can't check this app. Three reasons share the one badge, so the note says which applies. The+ /// Why Peel can't check this app. Four 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.private var unsupportedReason: Text {if app.isSystemProtected {Text("\(app.name) came with macOS. Software Update is what keeps it current, so Peel has nothing to ask.")+ } else if app.version == nil {+ 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 {Text("The App Store doesn’t give a Mac version of \(app.name) that Peel can compare. It lists some apps under one entry for all the devices they run on, with the iPhone’s version, and nothing for an app it doesn’t sell in this region. The App Store app itself knows when there is an update.")} else {