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
Keep a group given to an app out of Orphaned Files, all of it
Țugui Dragoș521065a08072
diff --git a/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swift b/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swiftindex 31262616..b043210e 100644--- a/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swift+++ b/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swift@@ -160,9 +160,10 @@ public struct OrphanScanner: Sendable {uniquingKeysWith: { first, _ in first })let folders = manifestFolders+ let given = Set(owners.filter { here.contains($0.value.lowercased()) }.keys.map { $0.lowercased() })let kept = found.compactMap { entry -> (identifier: String, item: OrphanItem, holds: Bool?)? inguard !exclusions.excludes(entry.item.url), !exclusions.excludes(bundleIdentifier: entry.identifier),- !(owners[entry.identifier.lowercased()].map { here.contains($0.lowercased()) } ?? false),+ !Self.isInAGroup(entry.identifier, among: given),!Self.servesAProgram(entry.item.url, in: folders)else { return nil }let holds = exclusions.holdsSomething(entry.item.url)@@ -507,6 +508,13 @@ public struct OrphanScanner: Sendable {}}+ /// Whether `identifier` falls in one of `groups`, as `group` gathers them: by its grouping key, the group's own or+ /// one inside it.+ static func isInAGroup(_ identifier: String, among groups: Set<String>) -> Bool {+ let key = groupingKey(for: identifier).lowercased()+ return groups.contains { key == $0 || key.hasPrefix($0 + ".") }+ }+/// The identifier without a team ID or `group.` in front, when what is left is reverse DNS. For example,/// "S8EX82NJP6.group.com.example.app" and "group.com.example.app" both group under "com.example.app".static func groupingKey(for identifier: String) -> String {diff --git a/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swiftindex 0b5c3de5..32cd3f45 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift@@ -733,6 +733,21 @@ struct OrphanScannerTests {#expect(Set(ownerGone.groups.map(\.identifier)) == ["org.example.helper", "org.example.other"])}+ @Test func aGroupGivenToAnInstalledAppStaysOutWithEveryIdentifierInIt() async throws {+ let directory = try TemporaryDirectory()+ try directory.file("home/Library/Preferences/org.example.helper.plist")+ try directory.file("home/Library/Caches/org.example.helper.ShipIt/update.zip")+ try directory.file("home/Library/Group Containers/ABCDE12345.org.example.helper/data.db")+ let scanner = scanner(in: directory)++ let listed = await scanner.scan(installedApps: installed)+ #expect(listed.groups.map(\.identifier) == ["org.example.helper"])+ #expect(listed.groups.first?.items.count == 3)++ let given = await scanner.scan(installedApps: installed, owners: ["org.example.helper": "com.installed.app"])+ #expect(given.groups.isEmpty)+ }+@Test func remembersWhichAppAGroupBelongsToUntilToldOtherwise() throws {let directory = try TemporaryDirectory()let owners = OrphanOwners(url: directory.url.appending(path: "orphan-owners.json"))