Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

Apple's own folders the deep search cannot read go unsaid

Țugui Dragoșca3b55c31432
diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverScanner.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverScanner.swift
index 365b7d1c..70daad0a 100644
--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverScanner.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverScanner.swift
@@ -239,8 +239,11 @@ public struct LeftoverScanner: Sendable {
} catch CocoaError.fileReadNoSuchFile {
continue
} catch {
- // It may hold the app's files, so it is said rather than passed over as empty.
- unreadable.append(folder)
+ // It may hold the app's files, so it is said rather than passed over as empty. A folder of
+ // Apple's own holds none of another app's.
+ if !ProtectedData.isApplesName(folder.lastPathComponent) {
+ unreadable.append(folder)
+ }
continue
}
ScanCount.current?.add(names.count)
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift
index 6406443f..4e983872 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift
@@ -361,6 +361,20 @@ struct LeftoverScannerTests {
#expect(!scan.needsFullDiskAccess)
}
+ /// A folder of Apple's own the deep search cannot look into, such as macOS's icon store in the Caches, holds none
+ /// of another app's files, so saying so on every app's page would only be noise.
+ @Test(.permissionsHold) func leavesApplesOwnFoldersItCannotReadUnsaid() async throws {
+ let directory = try TemporaryDirectory()
+ try directory.file("home/Library/Caches/com.apple.iconservices.store/cache.db")
+ try directory.setPermissions(0o000, of: "home/Library/Caches/com.apple.iconservices.store")
+ defer { try? directory.setPermissions(0o755, of: "home/Library/Caches/com.apple.iconservices.store") }
+
+ let scanner = LeftoverScanner(environment: environment(in: directory))
+ let scan = await scanner.scan(tunewell, installedApps: [tunewell])
+
+ #expect(scan.unreadableLocations.isEmpty)
+ }
+
@Test(.permissionsHold) func flagsItemsInReadOnlyLocationsAsRequiringPrivileges() async throws {
let directory = try TemporaryDirectory()
try directory.file("root/Library/LaunchDaemons/net.example.client.helper.plist")