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
A plug-in named like the app is selected only when its identifier agrees
Țugui Dragoș3892e148e19b
diff --git a/ARCHITECTURE.md b/ARCHITECTURE.mdindex 40c38c57..93064675 100644--- a/ARCHITECTURE.md+++ b/ARCHITECTURE.md@@ -62,11 +62,13 @@ Take the most common case, uninstalling an app. Every other page follows the samtop of the home folder, and more. A page's scan runs through its `ScanRun`, so a newer scan or the Stopbutton ends an older one, and it counts what it reads so the page can show progress.2. **Match.** For each file, `LeftoverMatcher` weighs the evidence that it belongs to the app: its bundle- identifier, the identifiers of what the app embeds, its application groups, its signing team, its name. The- answer is a `LeftoverMatch`: a confidence (`certain`, `likely`, or `possible`), the reason, the other- installed apps that claim the file too (with the apps of the same maker that macOS knows outside the- Applications folders), the other copies of the app that use it (any macOS knows, wherever they are, named by- their place), and, when Peel holds it back, why (`HoldBack`).+ identifier, the identifiers of what the app embeds, its application groups, its signing team, its name. A+ plug-in and a container named by a UUID are also weighed by the identifier they declare: a plug-in's name+ says what it does and a UUID says nothing, so the identifier decides whose they are. The answer is a+ `LeftoverMatch`: a confidence (`certain`, `likely`, or `possible`), the reason, the other installed apps that+ claim the file too (with the apps of the same maker that macOS knows outside the Applications folders), the+ other copies of the app that use it (any macOS knows, wherever they are, named by their place), and, when Peel+ holds it back, why (`HoldBack`).3. **Measure.** `FileSize` walks each folder on a thread of its own, with a time budget. A folder that doesn'tanswer in time, or that macOS won't open, has an unknown size, never zero, and every list shows it that way.4. **Plan.** The page shows every match with its reason. Only `certain` and `likely` matches that nothing elsediff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swiftindex c03a9827..230fcf3b 100644--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift@@ -113,6 +113,14 @@ public struct LeftoverMatch: Sendable, Hashable {LeftoverMatch(reason: reason, confidence: confidence, sharedWith: sharedWith, otherCopies: otherCopies, heldBack: heldBack, isAWord: isAWord)}+ /// Returns the same match, no surer than `ceiling`.+ func atMost(_ ceiling: MatchConfidence) -> LeftoverMatch {+ LeftoverMatch(+ reason: reason, confidence: min(confidence, ceiling), sharedWith: sharedWith, otherCopies: otherCopies,+ heldBack: heldBack, isAWord: isAWord+ )+ }+/// Combines two apps' claims on one item, cautiously and the same in either order: the weaker claim counts,/// and if either one is held back, so is the result.func combined(with other: LeftoverMatch) -> LeftoverMatch {diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverScanner.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverScanner.swiftindex 4409424b..ae5986b8 100644--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverScanner.swift+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverScanner.swift@@ -235,7 +235,7 @@ public struct LeftoverScanner: Sendable {for name in names {let url = folder.appending(path: name)let path = url.path(percentEncoded: false)- if let match = matcher.match(fileName: name, kind: kind, at: url), match.confidence >= .likely,+ if let match = Self.match(name, at: url, kind: kind, matcher: matcher), match.confidence >= .likely,!isSharedWithTheWholeMac(url, home: home) {guard !refuses(path, home) else { continue }found.append(await leftover(at: url, kind: kind, match: match, parent: parent, home: home, isInsideAnotherAppsFolder: isAnotherApps, measure: measure))@@ -328,15 +328,26 @@ public struct LeftoverScanner: Sendable {bundle: String) -> LeftoverMatch? {guard kind != .commandLineTools else { return leadsInside(bundle, link: url) }- let byName = matcher.match(fileName: name, kind: kind, at: url)guard let inside = runsSomethingInside(bundle, job: url, kind: kind) else {- guard byName == nil, let identifier = DeclaredIdentifier.of(url, kind: kind) else { return byName }- // `.elsewhere`, so no extension is taken off the identifier as if it were a file name.- return matcher.match(fileName: identifier, kind: .elsewhere, at: url)+ return match(name, at: url, kind: kind, matcher: matcher)}+ let byName = matcher.match(fileName: name, kind: kind, at: url)return byName?.confidence == .certain ? byName : inside}+ /// This app's claim on an item from its name and from the identifier it declares, which is read for a plug-in+ /// and for an item whose name answers nothing. The identifier says who made a plug-in: a claim through it+ /// replaces a weaker one on the name, and a name it does not back makes the plug-in only possible.+ private static func match(_ name: String, at url: URL, kind: SearchLocation.Kind, matcher: LeftoverMatcher) -> LeftoverMatch? {+ let byName = matcher.match(fileName: name, kind: kind, at: url)+ guard byName == nil || kind == .plugIns else { return byName }+ // `.elsewhere`, so no extension is taken off the identifier as if it were a file name.+ let declared = DeclaredIdentifier.of(url, kind: kind).flatMap { matcher.match(fileName: $0, kind: .elsewhere, at: url) }+ guard let byName else { return declared }+ guard let declared else { return byName.restsOnAName ? byName.atMost(.possible) : byName }+ return declared.confidence >= byName.confidence ? declared : byName+ }+/// True for a folder another installed app claims, or one Apple named for itself. A name found inside it/// is only a guess: `Caches/com.apple.python/Library/Developer` is not the Developer app's. Another copy of/// the app is no one else.diff --git a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swiftindex 7946228e..d8912c75 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift@@ -683,7 +683,8 @@ struct LeftoverScannerTests {#expect(folder.match.heldBack == .holdsKeys)}- /// Plug-ins are found in the user's Library and the system's, including inside a vendor's own folder.+ /// Plug-ins that declare the app's identifier are found in the user's Library and the system's, including inside+ /// a vendor's own folder.@Test func findsThePlugInsAnAppInstalled() async throws {let directory = try TemporaryDirectory()let massive = InstalledApp(@@ -691,9 +692,9 @@ struct LeftoverScannerTests {bundleIdentifier: "com.native-instruments.massive",name: "Massive")- try directory.file("home/Library/Audio/Plug-Ins/VST3/Massive.vst3/Contents/Info.plist", bytes: 512)- try directory.file("root/Library/Audio/Plug-Ins/Components/Massive.component/Contents/Info.plist", bytes: 512)- try directory.file("root/Library/Audio/Plug-Ins/VST/Native Instruments/Massive.vst/Contents/Info.plist", bytes: 512)+ try directory.file("home/Library/Audio/Plug-Ins/VST3/Massive.vst3/Contents/Info.plist", contents: plist("com.native-instruments.massive.vst3"))+ try directory.file("root/Library/Audio/Plug-Ins/Components/Massive.component/Contents/Info.plist", contents: plist("com.native-instruments.massive.au"))+ try directory.file("root/Library/Audio/Plug-Ins/VST/Native Instruments/Massive.vst/Contents/Info.plist", contents: plist("com.native-instruments.massive.vst"))try directory.file("root/Library/QuickLook/Somebody Else.qlgenerator/Contents/Info.plist", bytes: 512)let scan = await LeftoverScanner(environment: environment(in: directory)).scan(massive, installedApps: [massive])@@ -728,6 +729,52 @@ struct LeftoverScannerTests {#expect(scan.leftovers.first?.match.isRecommended == false)}+ /// Another maker's plug-in can do what the app is called: the identifier it declares is not the app's, so its+ /// name makes it only possible, and inside a vendor's folder, where only a strong claim is taken, it is not listed.+ @Test func anotherMakersPlugInWithTheAppsNameIsNotSelected() async throws {+ let directory = try TemporaryDirectory()+ let compressor = InstalledApp(+ url: URL(filePath: "/Applications/Compressor.app"),+ bundleIdentifier: "net.example.compressor",+ name: "Compressor"+ )+ let plugIns = "root/Library/Audio/Plug-Ins"+ try directory.file("\(plugIns)/Components/Compressor.component/Contents/Info.plist", contents: plist("org.example.dynamics.compressor"))+ try directory.file("\(plugIns)/VST3/Dynamics/Compressor.vst3/Contents/Info.plist", contents: plist("org.example.dynamics.compressor"))+ try directory.file("\(plugIns)/VST3/Compressor.vst3/Contents/Info.plist", contents: plist("net.example.compressor.vst3"))++ let scan = await LeftoverScanner(environment: environment(in: directory)).scan(compressor, installedApps: [compressor])++ let folder = directory.url.appending(path: plugIns).path(percentEncoded: false)+ let found = Dictionary(uniqueKeysWithValues: scan.leftovers.map {+ (String($0.url.path(percentEncoded: false).dropFirst(folder.count + 1)), $0.match)+ })+ #expect(found.keys.sorted() == ["Components/Compressor.component", "VST3/Compressor.vst3"])+ #expect(found["Components/Compressor.component"]?.confidence == .possible)+ #expect(found["Components/Compressor.component"]?.isRecommended == false)+ #expect(found["VST3/Compressor.vst3"]?.reason == .bundleIdentifierPrefix)+ #expect(found["VST3/Compressor.vst3"]?.isRecommended == true)+ }++ /// A plug-in is claimed through the identifier it declares when that says more than its name, which may only+ /// start with the app's or say nothing of it, inside a vendor's folder as well.+ @Test func aPlugInsIdentifierOutweighsAWeakerName() async throws {+ let directory = try TemporaryDirectory()+ let tunewell = InstalledApp(+ url: URL(filePath: "/Applications/Tunewell.app"),+ bundleIdentifier: "net.example.tunewell",+ name: "Tunewell"+ )+ let plugIns = "root/Library/Audio/Plug-Ins"+ try directory.file("\(plugIns)/Components/Tunewell Reverb.component/Contents/Info.plist", contents: plist("net.example.tunewell.reverb"))+ try directory.file("\(plugIns)/VST3/Example Audio/Space.vst3/Contents/Info.plist", contents: plist("net.example.tunewell.space"))++ let scan = await LeftoverScanner(environment: environment(in: directory)).scan(tunewell, installedApps: [tunewell])++ #expect(Set(scan.leftovers.map(\.url.lastPathComponent)) == ["Tunewell Reverb.component", "Space.vst3"])+ #expect(scan.leftovers.allSatisfy { $0.match.reason == .bundleIdentifierPrefix && $0.match.isRecommended })+ }+/// A launchd job is named by whoever wrote it, so a job whose program sits inside the app is the app's,/// whatever its file is called. That match is certain and outranks a weaker match on the file name.@Test func findsAJobByTheProgramItRuns() async throws {diff --git a/SAFETY.md b/SAFETY.mdindex 0628296c..26f19ef0 100644--- a/SAFETY.md+++ b/SAFETY.md@@ -135,7 +135,9 @@ macOS knows anywhere, such as an older copy in Downloads or one on another disk,the same maker kept outside the Applications folders, such as a Nightly build on another disk, counts like oneinside them. Something matched by the app's name alone inside another app's folder, or one of Apple's, is shown andnever selected, since it is most likely that app's data about this one; so is something matched by name alone at the-top of your home folder or of a Library, where a name is only a guess. And nothing at all is selected for an app+top of your home folder or of a Library, where a name is only a guess. A plug-in's name says what it does rather than+who made it, so a plug-in called like the app is selected only when the identifier it declares is the app's or its+maker's: another maker's plug-in with the app's name is never selected. And nothing at all is selected for an appthat would stay: one macOS keeps, one the helper may not move, or one that needs the helper while it cannot act.When you remove several apps at once and deselect one of them, it stays too: its files leave the selection, those itshares with the other apps included, and selecting it again brings them back.