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
Leave out the files of another app of the maker that macOS knows
Țugui Dragoș4e2cfc5ce519
diff --git a/ARCHITECTURE.md b/ARCHITECTURE.mdindex 63def595..cb1ab1fa 100644--- a/ARCHITECTURE.md+++ b/ARCHITECTURE.md@@ -86,7 +86,9 @@ the Homebrew page's uninstall and cleanups are Homebrew's own.`LeftoverMatch`: a confidence (`certain`, `likely`, or `possible`), the reason, the other installed apps thatclaim the file too (with the apps of the same maker that macOS knows outside the Applications folders, theapps Peel saw installed before, whose identifiers stay theirs once they are gone, and, for a file only the app's- name claims, another maker's app whose name holds that name as whole words), the+ name claims, another maker's app whose name holds that name as whole words; a file tied to the app only by its+ maker's identifier or team, and named for another app of that maker that macOS knows anywhere, such as a build, is+ not listed), theother copies of the app that use it (any macOS knows, wherever they are, named by their place), and, when Peelholds it back, why (`HoldBack`).3. **Measure.** `FileSize` walks each folder on a thread of its own, with a time budget. A size is what movingdiff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverMatcher.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverMatcher.swiftindex 75309d37..8daf9271 100644--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverMatcher.swift+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverMatcher.swift@@ -142,8 +142,13 @@ struct LeftoverMatcher: Sendable {share(with: other)}}- if evidence.reason == .bundleIdentifierPrefix {- sharedWith.formUnion(appsElsewhere(answeringTo: key))+ if evidence.reason == .bundleIdentifierPrefix, let identifier = target.identifier {+ sharedWith.formUnion(appsElsewhere(answeringTo: key, longerThan: Identifier.componentCount(of: identifier)))+ }+ if evidence.family == .maker {+ let named = evidence.reason == .teamIdentifier ? String(key.dropFirst(target.teamPrefix?.count ?? 0)) : key+ // What is named for another app of the maker that macOS knows, such as a build Xcode keeps, is that app's.+ guard appsElsewhere(answeringTo: named, longerThan: 2).isEmpty else { return nil }}return LeftoverMatch(reason: evidence.reason,@@ -156,14 +161,12 @@ struct LeftoverMatcher: Sendable {/// Identifiers of apps macOS knows, wherever they are installed, that `key` may belong to. The list of/// installed apps covers only the two Applications folders, and Chrome Canary on another disk must still- /// count as a rival for `com.google.Chrome.canary`. macOS is asked about each prefix of `key` with more- /// components than the app's identifier. An app found inside this bundle is the app's own helper, not a rival.- private func appsElsewhere(answeringTo key: String) -> [String] {- guard let identifier = target.identifier else { return [] }+ /// count as a rival for `com.google.Chrome.canary`. macOS is asked about each prefix of `key` with more than+ /// `components` components. An app found inside this bundle is the app's own helper, not a rival.+ private func appsElsewhere(answeringTo key: String, longerThan components: Int) -> [String] {let parts = key.split(separator: ".", omittingEmptySubsequences: false)- let own = identifier.split(separator: ".").count- guard parts.count > own else { return [] }- return ((own + 1)...parts.count).compactMap { length in+ guard parts.count > components else { return [] }+ return ((components + 1)...parts.count).compactMap { length inlet identifier = parts.prefix(length).joined(separator: ".")guard let url = registeredApp(identifier) else { return nil }let path = PathPattern.comparablePath(of: url)diff --git a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverMatcherTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverMatcherTests.swiftindex 65d7c584..59a9ee7d 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverMatcherTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverMatcherTests.swift@@ -94,6 +94,24 @@ struct LeftoverMatcherTests {#expect(try #require(match("com.google.Chrome.helper", in: .caches, for: chrome)).isRecommended)}+ @Test func whatAnotherAppOfTheMakerThatMacOSKnowsElsewhereNamesIsNotListed() throws {+ let atlas = app("org.example.atlas", name: "Atlas", team: "AAAAAAAAAA")+ let build = URL(filePath: "/Users/x/Library/Developer/Xcode/DerivedData/Harbor/Build/Products/Debug/Harbor.app")+ let known = ["org.example.harbor": build]++ #expect(match("org.example.harbor", in: .containers, for: atlas)?.confidence == .possible)+ #expect(match("org.example.harbor", in: .containers, for: atlas, registered: known) == nil)+ #expect(match("org.example.harbor.plist", in: .preferences, for: atlas, registered: known) == nil)+ #expect(match("org.example.harbor.helper", in: .caches, for: atlas, registered: known) == nil)+ #expect(match("AAAAAAAAAA.org.example.harbor", in: .groupContainers, for: atlas, registered: known) == nil)+ let catalystBuild = "maccatalyst.org.example.harbor"+ #expect(match(catalystBuild, in: .containers, for: atlas, registered: [catalystBuild: build]) == nil)+ #expect(match(catalystBuild, in: .containers, for: atlas, registered: known)?.confidence == .possible)++ let inside = ["org.example.harbor": atlas.url.appending(path: "Contents/Library/LoginItems/Harbor.app")]+ #expect(match("org.example.harbor", in: .containers, for: atlas, registered: inside)?.confidence == .possible)+ }+/// Another copy of the app uses the same files wherever it is, so a file both claim is shared with that copy,/// known by its place, since the identifier cannot tell the two apart. What only this copy embeds stays its own.@Test func anotherCopyOfTheAppSharesWhatItUsesAndNothingMore() throws {diff --git a/SAFETY.md b/SAFETY.mdindex b411053a..70c5796c 100644--- a/SAFETY.md+++ b/SAFETY.md@@ -269,9 +269,10 @@ Only matches Peel is `certain` or `likely` about, and only when nothing else insof the app uses: one macOS knows anywhere, such as an older copy in Downloads or one on another disk, named by whereit is. An app of the same maker kept outside the Applications folders, such as a Nightly build on another disk, countslike one inside them, and so does one Peel saw installed before: the files named for a Nightly you removed are its,- not this app's, and Orphaned Files lists them under it. A browser's folder another installed browser reads too is- shared with it: every build of Brave reads the native messaging manifests other apps, such as a password manager,- leave in Chrome's folders, so uninstalling Chrome leaves them while Brave is installed.+ not this app's, and Orphaned Files lists them under it. What is named for another app of the same maker that macOS+ knows anywhere, such as a build Xcode keeps, is that app's and is not listed. A browser's folder another installed+ browser reads too is shared with it: every build of Brave reads the native messaging manifests other apps, such as a+ password manager, leave in Chrome's folders, so uninstalling Chrome leaves them while Brave is installed.- **A name alone is a guess.** Something matched by the app's name alone inside a folder named for neither the appnor its maker, such as another app's, one of Apple's, or a command-line tool's, is shown and never selected, since afolder of that name may be that program's own; so is something matched by name alone at the top of your home folder