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
Know a gone Safari web app's settings as its orphans
Țugui Dragoșa8b54546725f
diff --git a/Packages/PeelCore/Sources/PeelCore/Orphans/AppOwnership.swift b/Packages/PeelCore/Sources/PeelCore/Orphans/AppOwnership.swiftindex 4789167d..1a7fd386 100644--- a/Packages/PeelCore/Sources/PeelCore/Orphans/AppOwnership.swift+++ b/Packages/PeelCore/Sources/PeelCore/Orphans/AppOwnership.swift@@ -21,8 +21,11 @@ struct AppOwnership: Sendable {return true}// macOS knows an app by its bundle identifier, never by a container's name with a team or `group.` in front.+ // A Safari web app's identifier is Safari's web app template followed by its own UUID, and that template, an+ // app Launch Services knows, is no owner of the web app's files.var components = OrphanScanner.groupingKey(for: identifier).split(separator: ".")- while components.count >= 3 {+ let shortest = SafariWebApp.isIdentifier(identifier) ? components.count : 3+ while components.count >= shortest {if isRegisteredApp(components.joined(separator: ".")) {return true}diff --git a/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanConfidence.swift b/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanConfidence.swiftindex eae6c286..75f2363a 100644--- a/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanConfidence.swift+++ b/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanConfidence.swift@@ -100,9 +100,11 @@ public struct OrphanConfidence: Sendable, Hashable {}/// Whether two identifiers belong to one app. A helper runs under its app's identifier or a longer one. A- /// prefix counts only with three components or more, since two name a maker, not an app.+ /// prefix counts only with three components or more, since two name a maker, not an app. A Safari web app's+ /// identifier begins with Safari's, and is still an app of its own.static func isOneApp(_ one: String, _ other: String) -> Bool {if one == other { return true }+ guard !SafariWebApp.isIdentifier(one), !SafariWebApp.isIdentifier(other) else { return false }let (short, long) = one.count < other.count ? (one, other) : (other, one)return Identifier.componentCount(of: short) >= 3 && long.hasPrefix(short + ".")}diff --git a/Packages/PeelCore/Tests/PeelCoreTests/OrphanConfidenceTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/OrphanConfidenceTests.swiftindex 60f3cf4c..eacb1542 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/OrphanConfidenceTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/OrphanConfidenceTests.swift@@ -102,6 +102,15 @@ struct OrphanConfidenceTests {#expect(OrphanConfidence.judge(old, running: ["com.example.apple"], now: now).level == .certain)}+ @Test("A Safari web app is its own app: Safari running, or another web app, says nothing about it")+ func safariRunningSaysNothingOfAWebApp() {+ let identifier = "com.apple.Safari.WebApp.0E4F6A2C-1B3D-4E5F-8A9B-0C1D2E3F4A5B"+ let webApp = group(identifier: identifier, written: 400 * 24 * 60 * 60)+ #expect(OrphanConfidence.judge(webApp, running: ["com.apple.Safari"], now: now).level == .certain)+ #expect(OrphanConfidence.judge(webApp, running: ["com.apple.Safari.WebApp"], now: now).level == .certain)+ #expect(OrphanConfidence.judge(webApp, running: [identifier], now: now).reasons == [.running])+ }+@Test("An app Peel watched leave is the strongest thing it can say")func peelWatchedItGo() {let judged = OrphanConfidence.judge(group(written: 60 * 24 * 60 * 60, remembered: left("Numi")), now: now)diff --git a/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swiftindex 05af8cd3..cca9a5de 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift@@ -316,6 +316,7 @@ struct OrphanScannerTests {/// The settings a Safari web app leaves are named by its own identifier, which begins with `com.apple.`. Once/// the web app is gone they are orphans, while an installed web app keeps its own and Safari keeps Safari's.+ /// Launch Services is this Mac's own, which knows Safari's web app template, `com.apple.Safari.WebApp`.@Test func findsTheSettingsASafariWebAppThatLeftKept() async throws {let directory = try TemporaryDirectory()let gone = "com.apple.Safari.WebApp.0E4F6A2C-1B3D-4E5F-8A9B-0C1D2E3F4A5B"@@ -332,7 +333,12 @@ struct OrphanScannerTests {isASafariWebApp: true)- let groups = await scanner(in: directory).scan(installedApps: installed + [news], remembered: [wiki]).groups+ let scanner = OrphanScanner(environment: SearchEnvironment(+ homeDirectory: directory.url.appending(path: "home", directoryHint: .isDirectory),+ rootDirectory: directory.url.appending(path: "root", directoryHint: .isDirectory)+ ))++ let groups = await scanner.scan(installedApps: installed + [news], remembered: [wiki]).groups#expect(groups.map(\.identifier) == [gone])#expect(groups.first?.items.map(\.url.lastPathComponent) == ["\(gone).plist"])