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 another program's folder out of the note about unreadable folders
Țugui Dragoș35a80a90be5d
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex e896321c..0deb8a35 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -148,6 +148,9 @@ its changes the way [Keep a Changelog](https://keepachangelog.com/) suggests.Services: Peel draws its icon from the app's own files.- While a removal of many items goes on, Peel reads again, once a second, which programs hold a file open, so a file anapp opened meanwhile stays where it is.+- An app's page, `peel leftovers`, and `peel uninstall` no longer say Peel couldn't look inside a folder named by+ another program's identifier, such as Microsoft AutoUpdate's cache in `/Library/Caches`: it holds nothing of the+ app's.#### Orphaned Filesdiff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverScanner.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverScanner.swiftindex 312d6d62..8626c22b 100644--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverScanner.swift+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverScanner.swift@@ -270,13 +270,16 @@ public struct LeftoverScanner: Sendable {) async -> (found: [Leftover], wasCutShort: Bool, unreadable: [URL]) {let kind = location.kindlet locationLength = location.url.pathComponents.count- let search: NestedSearch.Findings<Found> = await NestedSearch.walk(inside: folders, limit: limit) {- url, name, parent, canLookInside in- let path = url.path(percentEncoded: false)+ func matching(_ url: URL, named name: String) -> LeftoverMatch? {// A browser's manifest is whoever's program it runs, whatever it is called.- let match = url.deletingLastPathComponent().lastPathComponent.lowercased() == "nativemessaginghosts"+ url.deletingLastPathComponent().lastPathComponent.lowercased() == "nativemessaginghosts"? runsSomethingInside(bundle, manifest: url): Self.match(name, at: url, kind: kind, matcher: matcher, home: home)+ }+ let search: NestedSearch.Findings<Found> = await NestedSearch.walk(inside: folders, limit: limit) {+ url, name, parent, canLookInside in+ let path = url.path(percentEncoded: false)+ let match = matching(url, named: name)if let match, match.confidence >= .likely,!isSharedWithTheWholeMac(url, home: home) {guard !refuses(path, home), !exclusions.excludes(url) else { return .pass }@@ -292,7 +295,13 @@ public struct LeftoverScanner: Sendable {}let taken = await withoutWhatAppleInstalled(search.found, home: home, installedByApple: installedByApple)let found = await measured(taken, kind: kind, home: home, measure: measure)- return (found, search.wasCutShort, search.unreadable)+ // A program keeps its files in a folder named by its identifier (Apple's File System Programming Guide), so+ // one the app has no claim on holds none of its files, even where Peel can't look inside.+ let unreadable = search.unreadable.filter { folder in+ !Identifier.isReverseDNS(LeftoverMatcher.key(from: folder.lastPathComponent, kind: kind))+ || matching(folder, named: folder.lastPathComponent) != nil+ }+ return (found, search.wasCutShort, unreadable)}/// What a search took, less what one of Apple's packages installed, which is Apple's whatever its name says. Onlydiff --git a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swiftindex 3f58d984..f3e5954e 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift@@ -675,6 +675,40 @@ struct LeftoverScannerTests {#expect(scan.unreadableLocations.isEmpty)}+ @Test(.permissionsHold) func leavesAnotherProgramsFolderItCannotReadUnsaid() async throws {+ let directory = try TemporaryDirectory()+ try directory.file("home/Library/Caches/org.example.other/cache.db")+ try directory.file("home/.org.example.other/state")+ try directory.setPermissions(0o000, of: "home/Library/Caches/org.example.other")+ try directory.setPermissions(0o000, of: "home/.org.example.other")+ defer {+ try? directory.setPermissions(0o755, of: "home/Library/Caches/org.example.other")+ try? directory.setPermissions(0o755, of: "home/.org.example.other")+ }++ let scanner = LeftoverScanner(environment: environment(in: directory))+ let scan = await scanner.scan(tunewell, installedApps: [tunewell])++ #expect(scan.unreadableLocations.isEmpty)+ }++ @Test(.permissionsHold) func saysTheFoldersItCannotReadThatMayHoldTheAppsFiles() async throws {+ let directory = try TemporaryDirectory()+ try directory.file("home/Library/Caches/Vendor/net.example.shared/cache.db")+ try directory.file("home/Library/Caches/Shared Data/cache.db")+ try directory.setPermissions(0o000, of: "home/Library/Caches/Vendor/net.example.shared")+ try directory.setPermissions(0o000, of: "home/Library/Caches/Shared Data")+ defer {+ try? directory.setPermissions(0o755, of: "home/Library/Caches/Vendor/net.example.shared")+ try? directory.setPermissions(0o755, of: "home/Library/Caches/Shared Data")+ }++ let scanner = LeftoverScanner(environment: environment(in: directory))+ let scan = await scanner.scan(tunewell, installedApps: [tunewell])++ #expect(Set(scan.unreadableLocations.map(\.url.lastPathComponent)) == ["net.example.shared", "Shared Data"])+ }+@Test(.permissionsHold) func flagsItemsInReadOnlyLocationsAsRequiringPrivileges() async throws {let directory = try TemporaryDirectory()try directory.file("root/Library/LaunchDaemons/net.example.client.helper.plist")