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
Make a round stop for a Mac with no network, and let Stop reach Rescan's
Țugui Dragoș122c8ab4e3f8
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstringsindex a7e130d7..1f017bf8 100644--- a/Localization/Peel/Localizable.xcstrings+++ b/Localization/Peel/Localizable.xcstrings@@ -207089,7 +207089,7 @@"es" : {"stringUnit" : {"state" : "translated",- "value" : "Actualizada a %@"+ "value" : "Al día a fecha de %@"}},"fr" : {@@ -207131,13 +207131,13 @@"pt" : {"stringUnit" : {"state" : "translated",- "value" : "Atualizado em %@"+ "value" : "Em dia em %@"}},"ro" : {"stringUnit" : {"state" : "translated",- "value" : "Actualizată la %@"+ "value" : "La zi la data de %@"}},"ru" : {@@ -211978,6 +211978,112 @@}}},+ "Website" : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Web"+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Website"+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Sitio web"+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Site web"+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Sito web"+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Webサイト"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "웹사이트"+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Website"+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Witryna"+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Site"+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Site web"+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Сайт"+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Webbplats"+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Web Sitesi"+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Вебсайт"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "网站"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "網站"+ }+ }+ }+ },"What %@ is for" : {"localizations" : {"cs" : {diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Commands/AppCommands.swift b/Packages/PeelCore/Sources/PeelCommandLine/Commands/AppCommands.swiftindex ce388201..0b13e106 100644--- a/Packages/PeelCore/Sources/PeelCommandLine/Commands/AppCommands.swift+++ b/Packages/PeelCore/Sources/PeelCommandLine/Commands/AppCommands.swift@@ -810,9 +810,9 @@ struct UpdatesCommand: AsyncParsableCommand {init(app: InstalledApp, status: UpdateStatus, isWaiting: Bool) {self.app = AppRecord(app)switch status {- case .updateAvailable(let version, _, _):+ case .updateAvailable:self.status = isWaiting ? "updateAvailable" : "skipped"- availableVersion = version+ availableVersion = status.displayVersioncase .upToDate:self.status = "upToDate"availableVersion = nildiff --git a/Packages/PeelCore/Sources/PeelCore/Apps/AppCatalog.swift b/Packages/PeelCore/Sources/PeelCore/Apps/AppCatalog.swiftindex 1751fdf3..2f1d8b5b 100644--- a/Packages/PeelCore/Sources/PeelCore/Apps/AppCatalog.swift+++ b/Packages/PeelCore/Sources/PeelCore/Apps/AppCatalog.swift@@ -113,7 +113,7 @@ public enum AppCatalog {@concurrentpublic static func scan(in directories: [URL]) async -> AppScan {- await scan(in: directories, within: FileSize.budget) { appBundles(in: $0, unless: $1) }+ await scan(in: directories, within: FileSize.budget, walking: { appBundles(in: $0, unless: $1) })}/// Walks one folder for `scan(in:)`, until `isGivenUp` says nobody waits anymore. A parameter so a test can stand@@ -127,7 +127,8 @@ public enum AppCatalog {/// among what could not be read, and the others are listed meanwhile.@concurrentstatic func scan(- in directories: [URL], within budget: TimeInterval, walking walk: @escaping Walk+ in directories: [URL], within budget: TimeInterval, walking walk: @escaping Walk,+ reading readApp: @escaping @Sendable (URL) -> InstalledApp? = { Reading.of($0) }) async -> AppScan {let walks = await withTaskGroup(of: (index: Int, walk: (bundles: [URL], unreadable: [URL])?).self) { group infor (index, directory) in directories.enumerated() {@@ -139,20 +140,55 @@ public enum AppCatalog {let unanswered = zip(directories, walks).filter { $0.1 == nil }.map(\.0)let bundles = Set(answered.flatMap(\.1.bundles))- let read = await withTaskGroup(of: (bundle: URL, app: InstalledApp?).self) { group in- for bundle in bundles {- group.addTask { (bundle, Task.isCancelled ? nil : Reading.of(bundle)) }+ // A folder the person chose can be on a disk that lists from memory and then doesn't answer, so its apps are+ // read on threads of their own, and once one doesn't answer in time the rest of that folder isn't asked. The+ // Applications folders are on this Mac.+ let usual = Set(standardDirectories.map(PathPattern.comparablePath))+ let waited = directories.filter { !usual.contains(PathPattern.comparablePath(of: $0)) }+ func folder(of bundle: URL) -> URL? {+ let path = PathPattern.comparablePath(of: bundle)+ return waited.first { PathComponents.isPath(path, inside: PathPattern.comparablePath(of: $0)) }+ }+ var stalled: Set<URL> = []+ var unasked: [URL] = []+ let read = await withTaskGroup(of: (bundle: URL, app: InstalledApp?, answered: Bool).self) { group in+ var pending = bundles.makeIterator()+ func askNext() {+ while let bundle = pending.next() {+ let waitedFor = folder(of: bundle)+ if let waitedFor, stalled.contains(waitedFor) {+ unasked.append(bundle)+ continue+ }+ group.addTask {+ guard !Task.isCancelled else { return (bundle, nil, true) }+ guard waitedFor != nil else { return (bundle, readApp(bundle), true) }+ let answer = await SlowRead.answer(within: budget) { _ in readApp(bundle) }+ return answer.map { (bundle, $0, true) } ?? (bundle, nil, false)+ }+ return+ }+ }+ for _ in 0..<max(ProcessInfo.processInfo.activeProcessorCount, 2) {+ askNext()+ }+ var read: [(bundle: URL, app: InstalledApp?, answered: Bool)] = []+ while let result = await group.next() {+ if !result.answered, let waitedFor = folder(of: result.bundle) { stalled.insert(waitedFor) }+ read.append(result)+ askNext()}- return await group.reduce(into: [(bundle: URL, app: InstalledApp?)]()) { $0.append($1) }+ return read}guard !Task.isCancelled else { return AppScan(apps: [], unreadable: [], needsFullDiskAccess: false) }Reading.forget(inside: answered.map { followingALink($0.0) }, except: bundles)- let closedApps = read.filter { $0.app == nil && AppInspector.isClosed($0.bundle) }.map(\.bundle)+ let closedApps = read.filter { $0.answered && $0.app == nil && AppInspector.isClosed($0.bundle) }.map(\.bundle)+ let silent = read.filter { !$0.answered }.map(\.bundle) + unaskedlet refused = answered.flatMap(\.1.unreadable) + closedAppsreturn AppScan(apps: sorted(read.compactMap(\.app)),- unreadable: (refused + unanswered)+ unreadable: (refused + unanswered + silent).sorted { $0.path(percentEncoded: false) < $1.path(percentEncoded: false) },needsFullDiskAccess: refused.contains { FullDiskAccess.canList($0) == .missing })diff --git a/Packages/PeelCore/Sources/PeelCore/Apps/AppFolders.swift b/Packages/PeelCore/Sources/PeelCore/Apps/AppFolders.swiftindex 9ee022f0..0be4ddbe 100644--- a/Packages/PeelCore/Sources/PeelCore/Apps/AppFolders.swift+++ b/Packages/PeelCore/Sources/PeelCore/Apps/AppFolders.swift@@ -113,7 +113,11 @@ public struct AppFolders: Sendable {if broad.contains(path) { return .tooBroad }// A whole disk other than the startup disk, and macOS's own folders, which hold no app of anyone else's.let names = PathComponents.of(path)- if names.count == 2 && names[0] == "volumes" || names.first == "system" { return .tooBroad }+ if names.count == 2 && names[0] == "volumes" { return .tooBroad }+ // `/System/Volumes/Data` is every folder of the data volume again, under another name.+ if names.first == "system", PathComponents.of(folded(PathPattern.canonical(folder))).first == "system" {+ return .tooBroad+ }if TrashService.isAtOrInsideATrash(folder, home: home) { return .inATrash }// Listing a folder a cloud keeps can download what it holds.if isInTheCloud(folder) { return .inTheCloud }diff --git a/Packages/PeelCore/Sources/PeelCore/Apps/AppListFilter.swift b/Packages/PeelCore/Sources/PeelCore/Apps/AppListFilter.swiftindex 630cee36..de5ce429 100644--- a/Packages/PeelCore/Sources/PeelCore/Apps/AppListFilter.swift+++ b/Packages/PeelCore/Sources/PeelCore/Apps/AppListFilter.swift@@ -32,7 +32,7 @@ public struct AppListFilter: Sendable, Hashable {public func keeps(_ app: InstalledApp, source: AppSource, developer appsDeveloper: String?, isUnused: Bool) -> Bool {- if !text.isEmpty, !SearchText.matches(app.name, text),+ if !text.isEmpty, !app.names.contains(where: { SearchText.matches($0, text) }),!(app.bundleIdentifier.map { SearchText.matches($0, text) } ?? false),!(appsDeveloper.map { SearchText.matches($0, text) } ?? false) {return falsediff --git a/Packages/PeelCore/Sources/PeelCore/Updates/Appcast.swift b/Packages/PeelCore/Sources/PeelCore/Updates/Appcast.swiftindex 75c85d1a..ddaab25f 100644--- a/Packages/PeelCore/Sources/PeelCore/Updates/Appcast.swift+++ b/Packages/PeelCore/Sources/PeelCore/Updates/Appcast.swift@@ -11,6 +11,8 @@ struct AppcastItem: Equatable {/// `sparkle:hardwareRequirements`, in lowercase. Sparkle knows one: `arm64`, a release for Apple silicon only.var hardwareRequirements: Set<String> = []var releaseNotes: URL?+ /// Whether `releaseNotes` is only the item's `link`, which Sparkle documents as the product's page.+ var notesAreTheProductsPage = false/// The page `sparkle:releaseNotesLink` names, which holds what is new. Unlike `releaseNotes`, never the product/// page an item's `link` names.var notesPage: URL?@@ -174,6 +176,9 @@ enum Appcast {item.releaseNotes =["sparkle:releaseNotesLink", "releaseNotesLink", "sparkle:fullReleaseNotesLink", "link"].lazy.compactMap { self.notes[$0].flatMap { Appcast.preferred($0) } }.first+ item.notesAreTheProductsPage = item.releaseNotes != nil+ && ["sparkle:releaseNotesLink", "releaseNotesLink", "sparkle:fullReleaseNotesLink"]+ .allSatisfy { self.notes[$0] == nil }item.notesPage = ["sparkle:releaseNotesLink", "releaseNotesLink"].lazy.compactMap { self.notes[$0].flatMap { Appcast.preferred($0) } }.firstif let description = Appcast.preferred(descriptions) {diff --git a/Packages/PeelCore/Sources/PeelCore/Updates/UpdateChecker.swift b/Packages/PeelCore/Sources/PeelCore/Updates/UpdateChecker.swiftindex b8711681..03179f49 100644--- a/Packages/PeelCore/Sources/PeelCore/Updates/UpdateChecker.swift+++ b/Packages/PeelCore/Sources/PeelCore/Updates/UpdateChecker.swift@@ -260,7 +260,10 @@ public struct UpdateChecker: Sendable {}guard isNewer else { return UpdateAnswer(status: .upToDate) }return UpdateAnswer(- status: .updateAvailable(version: latest, source: .developer, releaseNotes: item.releaseNotes),+ status: .updateAvailable(+ version: latest, source: .developer, releaseNotes: item.releaseNotes,+ linkIsTheProductsPage: item.notesAreTheProductsPage ? true : nil+ ),notes: item.notes,notesPage: item.notesPage)@@ -314,14 +317,14 @@ public struct UpdateChecker: Sendable {case .notListed:// An app the store just offered an update for is believed unlisted only when the answer before this// one said so too; a first such answer is asked again later, as a failed check.- if case .updateAvailable(_, .appStore, _) = earlier, !notListedBefore {+ if case .updateAvailable(_, .appStore, _, _) = earlier, !notListedBefore {return UpdateAnswer(status: .failed, isNotListed: true)}return UpdateAnswer(status: .unsupported, isNotListed: true)case .listed(let latest, let page, let developer, let notes):// The App Store never goes back to an older version, so an answer older than the update it gave for this// build comes from a copy of its catalog that isn't up to date yet, and is asked again later.- if case .updateAvailable(let found, .appStore, _) = earlier,+ if case .updateAvailable(let found, .appStore, _, _) = earlier,VersionComparison.isNewer(found, than: latest) {return UpdateAnswer(status: .failed, developer: developer)}@@ -440,6 +443,11 @@ public struct UpdateChecker: Sendable {UpdateAnswer(status: .failed, wasOffline: reply.wasOffline, reachedNoServer: reply.reachedNoServer)}+ /// Whether this Mac has a network path at all, which a round asks once before it asks about any app.+ public func canReachTheNetwork() async -> Bool {+ await isOnline()+ }+/// How many requests a server has answered, whatever it said, since this checker was made.public var serverReplies: Int { replies.count }@@ -550,7 +558,7 @@ public struct UpdateAnswer: Sendable, Hashable {/// The status to keep after `previous`: a check whose own source failed keeps an update that source found earlier,/// even where Homebrew answered in its place, and an update Homebrew reported is kept only while Homebrew gives it.public func following(_ previous: UpdateStatus?) -> UpdateStatus {- if (standsInFor ?? status) == .failed, let previous, case .updateAvailable(_, let source, _) = previous,+ if (standsInFor ?? status) == .failed, let previous, case .updateAvailable(_, let source, _, _) = previous,source != .homebrew {return previous}diff --git a/Packages/PeelCore/Sources/PeelCore/Updates/UpdateFeed.swift b/Packages/PeelCore/Sources/PeelCore/Updates/UpdateFeed.swiftindex c8e6fa77..1d86a719 100644--- a/Packages/PeelCore/Sources/PeelCore/Updates/UpdateFeed.swift+++ b/Packages/PeelCore/Sources/PeelCore/Updates/UpdateFeed.swift@@ -26,29 +26,43 @@ public enum UpdateSource: String, Sendable, Hashable, CaseIterable, Codable {/// The answer to an update check. It is `Codable` so answers survive a relaunch: apps are checked on a/// schedule, and a lost answer would leave an app with no status until its next check.public enum UpdateStatus: Sendable, Hashable, Codable {- case updateAvailable(version: String, source: UpdateSource = .developer, releaseNotes: URL? = nil)+ /// `linkIsTheProductsPage` when all a feed gives `releaseNotes` from is its `<link>`, which Sparkle documents as+ /// the product's page.+ case updateAvailable(+ version: String, source: UpdateSource = .developer, releaseNotes: URL? = nil, linkIsTheProductsPage: Bool? = nil+ )case upToDatecase unsupportedcase failedpublic var version: String? {- if case .updateAvailable(let version, _, _) = self { version } else { nil }+ if case .updateAvailable(let version, _, _, _) = self { version } else { nil }}/// The version to show the user. Homebrew adds what the download needs after a comma in a cask's version/// (`26.10.22,802`), so only the part before the comma is shown. The full string is what is compared and/// skipped.public var displayVersion: String? {- guard case .updateAvailable(let version, let source, _) = self else { return nil }- return source == .homebrew ? String(version.prefix { $0 != "," }) : version+ guard case .updateAvailable(let version, let source, _, _) = self else { return nil }+ return source == .homebrew ? Self.shownVersion(of: version) : version+ }++ /// A cask's version as a person reads it, without what Homebrew adds after a comma.+ public static func shownVersion(of version: String) -> String {+ String(version.prefix { $0 != "," })}public var releaseNotes: URL? {- if case .updateAvailable(_, _, let notes) = self { notes } else { nil }+ if case .updateAvailable(_, _, let notes, _) = self { notes } else { nil }+ }++ /// Whether `releaseNotes` leads to the product's page and not to notes.+ public var linkIsTheProductsPage: Bool {+ if case .updateAvailable(_, _, _, let isIt) = self { isIt == true } else { false }}public var source: UpdateSource? {- if case .updateAvailable(_, let source, _) = self { source } else { nil }+ if case .updateAvailable(_, let source, _, _) = self { source } else { nil }}/// Whether this answer still holds for an app, given what Homebrew says of the app now, nil where the app isn'tdiff --git a/Packages/PeelCore/Sources/PeelCore/Updates/UpdatePreferences.swift b/Packages/PeelCore/Sources/PeelCore/Updates/UpdatePreferences.swiftindex 96b3b87e..cb759329 100644--- a/Packages/PeelCore/Sources/PeelCore/Updates/UpdatePreferences.swift+++ b/Packages/PeelCore/Sources/PeelCore/Updates/UpdatePreferences.swift@@ -33,7 +33,7 @@ public struct UpdatePreferences: Sendable, Hashable {/// Whether `status` is an update worth showing: the app is not ignored and that version was not skipped./// The app list, the menu bar count, the notification, and the command line all ask this, so they agree.public func isWaiting(_ status: UpdateStatus?, for app: InstalledApp) -> Bool {- guard case .updateAvailable(let version, _, _) = status else { return false }+ guard case .updateAvailable(let version, _, _, _) = status else { return false }return !isIgnored(app) && skippedVersions[app.reference] != version}diff --git a/Packages/PeelCore/Tests/PeelCoreTests/AppCatalogTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/AppCatalogTests.swiftindex c295483c..3960ecfb 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/AppCatalogTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/AppCatalogTests.swift@@ -78,6 +78,28 @@ struct AppCatalogTests {#expect(!scan.needsFullDiskAccess)}+ @Test func aChosenFolderWhoseAppsDoNotAnswerCostsOneWaitAndIsSaid() async throws {+ let directory = try TemporaryDirectory()+ let folder = try directory.directory("Tools")+ let bundles = (0..<40).map { folder.appending(path: "App \($0).app", directoryHint: .isDirectory) }+ let asked = Mutex(0)+ let released = DispatchSemaphore(value: 0)+ defer { for _ in 0..<40 { released.signal() } }++ let scan = await AppCatalog.scan(+ in: [folder], within: 0.2, walking: { _, _ in (bundles, []) },+ reading: { _ in+ asked.withLock { $0 += 1 }+ _ = released.wait(timeout: .now() + 30)+ return nil+ }+ )++ #expect(scan.apps.isEmpty)+ #expect(Set(scan.unreadable) == Set(bundles))+ #expect(asked.withLock { $0 } <= max(ProcessInfo.processInfo.activeProcessorCount, 2))+ }+@Test func aReadingStoppedWhileAFolderDoesNotAnswerReturnsAtOnce() async throws {let sleeping = URL(filePath: "/nowhere/Sleeping", directoryHint: .isDirectory)let asked = Mutex(false)diff --git a/Packages/PeelCore/Tests/PeelCoreTests/AppFoldersTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/AppFoldersTests.swiftindex 2bf90f5d..3e973584 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/AppFoldersTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/AppFoldersTests.swift@@ -104,6 +104,17 @@ struct AppFoldersTests {#expect(AppFolders(url: list, home: directory.url).load()?.map(\.lastPathComponent) == ["Tools"])}+ @Test func aFolderReachedThroughTheDataVolumeIsJudgedAsItself() throws {+ let directory = try TemporaryDirectory()+ let tools = try directory.directory("Tools")+ let real = PathPattern.canonical(tools).path(percentEncoded: false)+ let reached = URL(filePath: "/System/Volumes/Data" + real, directoryHint: .isDirectory)++ #expect(reached.isThere)+ #expect(AppFolders.refusal(of: reached, home: directory.url) == nil)+ #expect(AppFolders.refusal(of: URL(filePath: "/System/Applications"), home: directory.url) == .tooBroad)+ }+@Test func namesWhatItLeavesOutAndKeepsItUntilItIsTakenOff() throws {let directory = try TemporaryDirectory()let tools = try directory.directory("Tools")diff --git a/Packages/PeelCore/Tests/PeelCoreTests/AppListFilterTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/AppListFilterTests.swiftindex 2221874e..3a501ee3 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/AppListFilterTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/AppListFilterTests.swift@@ -20,6 +20,15 @@ struct AppListFilterTests {#expect(!keeps(AppListFilter(text: "example inc"), developer: nil))}+ @Test func searchFindsAnAppByItsFileNameToo() {+ let translated = InstalledApp(+ url: URL(filePath: "/Applications/Calculator.app"), bundleIdentifier: "org.example.calc", name: "Calculatrice"+ )+ let filter = AppListFilter(text: "calculator")++ #expect(filter.keeps(translated, source: .direct, developer: nil, isUnused: false))+ }+@Test func eachFilterOnNarrowsTheList() {#expect(keeps(AppListFilter()))#expect(keeps(AppListFilter(sources: [.appStore, .direct])))diff --git a/Packages/PeelCore/Tests/PeelCoreTests/UpdateTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/UpdateTests.swiftindex 11f97919..a67503c8 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/UpdateTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/UpdateTests.swift@@ -398,6 +398,29 @@ struct UpdateFeedDetectionTests {#expect(electronApp.updateFeed == .electron(URL(string: "https://example.com/updates/latest-mac.yml")!))}+ @Test func showsACasksVersionWithoutWhatHomebrewAdds() {+ #expect(UpdateStatus.shownVersion(of: "26.10.22,802") == "26.10.22")+ #expect(UpdateStatus.shownVersion(of: "1.2") == "1.2")+ }++ @Test func tellsAProductsPageFromNotes() throws {+ func item(_ links: String) throws -> AppcastItem {+ let feed = """+ <rss xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle"><channel><item>+ <enclosure url="https://example.com/a.zip" sparkle:version="2"/>\(links)</item></channel></rss>+ """+ let items = Appcast.releases(in: Data(feed.utf8), systemVersion: "26.0", isAppleSilicon: true)+ return try #require(items?.first)+ }++ let page = try item("<link>https://example.com/</link>")+ #expect(page.releaseNotes == URL(string: "https://example.com/"))+ #expect(page.notesAreTheProductsPage)+ let notes = "<sparkle:releaseNotesLink>https://example.com/notes.html</sparkle:releaseNotesLink>"+ #expect(try !item("<link>https://example.com/</link>\(notes)").notesAreTheProductsPage)+ #expect(try !item("").notesAreTheProductsPage)+ }+@Test func findsTheUpdateServiceVSCodeNames() throws {let folder = try TemporaryDirectory()let product = #"""diff --git a/Peel/Model/AppLibrary.swift b/Peel/Model/AppLibrary.swiftindex ff0dad6d..69abf909 100644--- a/Peel/Model/AppLibrary.swift+++ b/Peel/Model/AppLibrary.swift@@ -374,6 +374,7 @@ final class AppLibrary {}}+ /// Stops the round Rescan started, which `recheck` runs.func stopCheckingEveryApp() {recheck?.cancel()rechecks += 1@@ -645,6 +646,8 @@ final class AppLibrary {// The list's own entry, not the caller's: a page that was open through an upgrade still holds the old build..map { app in apps.first { $0.id == app.id } ?? app }guard !wanted.isEmpty else { return }+ // With no network at all, each request would wait out its whole time, and nothing is learned of any app.+ guard await updateChecker.canReachTheNetwork() else { return }let asked = Dictionary(wanted.map { ($0.id, $0) }, uniquingKeysWith: { first, _ in first })let round = updateRounds.begin(wanted.map(\.id))// However the round ends, no app is left marked as being checked by it.@@ -734,7 +737,7 @@ final class AppLibrary {isNotListed: answer.isNotListed), for: app)// Only an answer that found this update can say what is new in it; a failed one keeps what was known.- if case .updateAvailable(let version, _, _) = kept, answer.status == kept {+ if case .updateAvailable(let version, _, _, _) = kept, answer.status == kept {if let notes = answer.notes {releaseNotes.record(.found(notes), of: identifier, version: version)} else if releaseNotes.asks(about: kept, of: app, with: updatePreferences, force: force) {@@ -1089,3 +1092,13 @@ final class AppLibrary {return name}}++/// Rescan's work: the reading of the folders, and then the round of checks it starts.+extension AppLibrary: StoppableWork {+ var isRunning: Bool { scanRun.isRunning || isCheckingEveryApp }++ func stop() {+ scanRun.stop()+ stopCheckingEveryApp()+ }+}diff --git a/Peel/Model/FoundLastTimeStore.swift b/Peel/Model/FoundLastTimeStore.swiftindex 32700cec..e0760da1 100644--- a/Peel/Model/FoundLastTimeStore.swift+++ b/Peel/Model/FoundLastTimeStore.swift@@ -34,13 +34,6 @@ struct Looked: Equatable {// What counts as found for each tool the menu bar panel lists. Each is nil until the tool has looked since Peel// opened, so what an earlier look found stays until the tool looks again.-extension AppLibrary {- /// The apps with an update waiting, as the menu bar counts them, once a round of checks is over.- var looked: Looked? {- hasLoaded && appsCheckingForUpdates.isEmpty ? Looked(count: menuBarUpdateCount, size: nil) : nil- }-}-extension OrphanLibrary {/// The groups, sized by what Peel can move with its helper. What only an administrator can move is no group of/// Peel's to free.diff --git a/Peel/PeelApp.swift b/Peel/PeelApp.swiftindex 886b5450..d0927164 100644--- a/Peel/PeelApp.swift+++ b/Peel/PeelApp.swift@@ -246,7 +246,6 @@ struct PeelApp: App {/// its own, so one that looks again leaves the others' dates as they were.private func followFindings() async {let tools: [(Tool, @MainActor @Sendable () -> Looked?)] = [- (.applications, { [library] in library.looked }),(.orphans, { [orphans] in orphans.looked }),(.intel, { [intel] in intel.looked }),(.homebrew, { [homebrew] in homebrew.looked }),diff --git a/Peel/Views/AppList.swift b/Peel/Views/AppList.swiftindex d28998a9..7cc968f4 100644--- a/Peel/Views/AppList.swift+++ b/Peel/Views/AppList.swift@@ -96,7 +96,7 @@ struct AppList: View {AppListMenu()}ToolbarItem {- RescanButton(isRunning: $isRescanning, isDisabled: library.isLoading, scan: library.scanRun) {+ RescanButton(isRunning: $isRescanning, isDisabled: library.isLoading, scan: library) {await library.rescan()}}diff --git a/Peel/Views/AppPageHeader.swift b/Peel/Views/AppPageHeader.swiftindex d77df224..7f3f49c5 100644--- a/Peel/Views/AppPageHeader.swift+++ b/Peel/Views/AppPageHeader.swift@@ -92,7 +92,7 @@ struct AppPageHeader: View {version: shown,notes: library.releaseNotes(of: plan.app),link: source == .appStore ? nil : status.releaseNotes.map {- ReleaseNotesLink(url: $0, title: source == .homebrew ? "Homepage" : "Release Notes")+ ReleaseNotesLink(url: $0, title: Self.linkTitle(of: status))}) {if let upgrade = library.upgrade(of: plan.app) {@@ -107,11 +107,17 @@ struct AppPageHeader: View {}}+ /// What the link of a waiting update leads to: a cask's homepage, the product's page a feed names, or notes.+ private static func linkTitle(of status: UpdateStatus) -> LocalizedStringResource {+ if status.source == .homebrew { return "Homepage" }+ return status.linkIsTheProductsPage ? "Website" : "Release Notes"+ }+private var moreMenu: some View {Menu {if waitingVersion != nil, let status = library.updateStatuses[plan.app.id], status.source != .appStore,let notes = status.releaseNotes {- Button("Release Notes") { NSWorkspace.shared.open(notes) }+ Button(Self.linkTitle(of: status)) { NSWorkspace.shared.open(notes) }}if let version = waitingVersion {Button("Skip This Version") { library.skip(version: version, for: plan.app) }diff --git a/Peel/Views/Settings/SettingsView.swift b/Peel/Views/Settings/SettingsView.swiftindex 63179bb9..c390d8af 100644--- a/Peel/Views/Settings/SettingsView.swift+++ b/Peel/Views/Settings/SettingsView.swift@@ -603,7 +603,7 @@ extension GeneralSettingsView {.font(.caption).foregroundStyle(.secondary)} else if let version = item.skippedVersion {- Text("Version \(version) skipped")+ Text("Version \(UpdateStatus.shownVersion(of: version)) skipped").font(.caption).foregroundStyle(.secondary)}diff --git a/PeelTests/AppLibraryTests.swift b/PeelTests/AppLibraryTests.swiftindex fad24e87..80248ebb 100644--- a/PeelTests/AppLibraryTests.swift+++ b/PeelTests/AppLibraryTests.swift@@ -310,9 +310,11 @@ private nonisolated final class TestClock: Sendable {library.checkEveryAppAgain()#expect(library.isCheckingEveryApp)+ #expect(library.isRunning, "Rescan's Stop would not be offered")let round = library.recheck- library.stopCheckingEveryApp()+ library.stop()+ #expect(!library.isRunning)#expect(!library.isCheckingEveryApp)#expect(round?.isCancelled == true)await round?.valuediff --git a/PeelTests/UpdateRoundTests.swift b/PeelTests/UpdateRoundTests.swiftindex 0e654e39..51df06ba 100644--- a/PeelTests/UpdateRoundTests.swift+++ b/PeelTests/UpdateRoundTests.swift@@ -27,6 +27,32 @@ private nonisolated final class TransportProtocol: URLProtocol, @unchecked Senda}@Suite(.serialized) @MainActor struct UpdateRoundTests {+ @Test func aRoundWithNoNetworkAsksNobodyAndKeepsEveryAppDue() async throws {+ let folder = FileManager.default.temporaryDirectory.appending(path: "PeelTests-\(UUID().uuidString)")+ defer { try? FileManager.default.removeItem(at: folder) }+ let made = try MadeUpDefaults()+ defer { made.forget() }+ let configuration = URLSessionConfiguration.ephemeral+ configuration.protocolClasses = [TransportProtocol.self]+ let checker = UpdateChecker(+ session: URLSession(configuration: configuration), appStoreWindow: RequestWindow.appStore,+ isOnline: { false }+ )+ let library = AppLibrary(+ defaults: made.defaults, updateChecker: checker,+ releaseNotesStore: ReleaseNotesStore(url: folder.appending(path: "notes.json"))+ )+ let bundle = try app("Offline", in: folder, feed: "https://feed.example.com/appcast.xml")+ #expect(await library.reveal([bundle]))+ let offline = try #require(library.apps.first { $0.bundleIdentifier == "org.example.offline" })++ await library.checkForUpdates([offline], force: true)++ #expect(library.shownUpdateStatus(of: offline) == nil)+ #expect(made.defaults.data(forKey: SettingsKey.updateMemory) == nil)+ #expect(library.appsCheckingForUpdates.isEmpty)+ }+private func app(_ name: String, in folder: URL, feed: String) throws -> URL {let bundle = folder.appending(path: "\(name).app", directoryHint: .isDirectory)try FileManager.default.createDirectory(