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 the list when a scan lands after
Țugui Dragoș63960f6c6dbc
diff --git a/Packages/PeelCore/Sources/PeelCore/Orphans/Orphan.swift b/Packages/PeelCore/Sources/PeelCore/Orphans/Orphan.swiftindex 7c0d8d25..623afda5 100644--- a/Packages/PeelCore/Sources/PeelCore/Orphans/Orphan.swift+++ b/Packages/PeelCore/Sources/PeelCore/Orphans/Orphan.swift@@ -118,8 +118,20 @@ public struct OrphanScan: Sendable {/// The same scan without the group `id`, as when the person said it belongs to an app.public func without(_ id: OrphanGroup.ID) -> OrphanScan {+ keeping { $0.id != id }+ }++ /// The same scan without the groups `owners` give to an app of `installedApps`, for a scan that ran while the+ /// person gave one away.+ public func leavingOut(given owners: [String: String], installedApps: [InstalledApp]) -> OrphanScan {+ let here = Set(installedApps.compactMap { $0.bundleIdentifier?.lowercased() })+ let given = Set(owners.filter { here.contains($0.value.lowercased()) }.keys.map { $0.lowercased() })+ return keeping { !OrphanScanner.isInAGroup($0.identifier, among: given) }+ }++ private func keeping(_ isKept: (OrphanGroup) -> Bool) -> OrphanScan {OrphanScan(- groups: groups.filter { $0.id != id }, unreadableLocations: unreadableLocations,+ groups: groups.filter(isKept), unreadableLocations: unreadableLocations,needsFullDiskAccess: needsFullDiskAccess, cutShortLocations: cutShortLocations,forAnAdministrator: forAnAdministrator, appsOnOtherDisks: appsOnOtherDisks)diff --git a/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swiftindex aed224e4..cf3a64b0 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift@@ -151,6 +151,26 @@ struct OrphanScannerTests {)}+ @Test func aScanThatLandsLeavesOutWhatThePersonGaveAwayMeanwhile() {+ let item = { (name: String) in+ OrphanItem(+ url: URL(filePath: "/Users/me/Library/Caches/\(name)"), kind: .caches, size: 1, modificationDate: nil,+ requiresPrivileges: false+ )+ }+ let groups = ["org.example.given", "org.example.kept", "org.example.gone"].map {+ OrphanGroup(identifier: $0, items: [item($0)])+ }+ let scan = OrphanScan(groups: groups, unreadableLocations: [])++ let left = scan.leavingOut(+ given: ["org.example.given": "com.installed.app", "org.example.gone": "org.example.notinstalled"],+ installedApps: installed+ )++ #expect(left.groups.map(\.identifier) == ["org.example.kept", "org.example.gone"])+ }+@Test func aTwoPartIdentifierNoAppDeclaredIsNeverAskedAboutAsAPrefix() {let asked = Mutex<[String]>([])let ownership = AppOwnership(installedApps: [], goneApps: ["com.example.gone"]) { identifier indiff --git a/Peel/Model/OrphanLibrary.swift b/Peel/Model/OrphanLibrary.swiftindex 046f1708..d09058b8 100644--- a/Peel/Model/OrphanLibrary.swift+++ b/Peel/Model/OrphanLibrary.swift@@ -69,7 +69,7 @@ final class OrphanLibrary {let installedApps = library.appslet owners = OrphanOwners().load()self.owners = owners- guard let result = await scanRun.run({+ guard let found = await scanRun.run({let remembered = await AppMemory().remember(installedApps)// What is currently running is better evidence than anything worked out from what is installed: a// helper or an agent can keep a folder that no app bundle claims.@@ -86,6 +86,8 @@ final class OrphanLibrary {}return scan}), library.readEverything else { return }+ // The owners this scan began with may have grown while it ran.+ let result = found.leavingOut(given: self.owners ?? [:], installedApps: library.apps)let remainingURLs = Set(result.groups.flatMap(\.items).filter { $0.leftAlone == nil }.map(\.url))scan = resultscannedAgainst = listing