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.

Say in Orphaned Files why a cache holding an editor's local history stays

Țugui Dragoșe964f6a95d88
diff --git a/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swift b/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swift
index 57d513bc..3635fcf6 100644
--- a/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swift
@@ -394,6 +394,8 @@ public struct OrphanScanner: Sendable {
.holdsKeys
} else if ProtectedData.holdsALibrary(path) {
.holdsALibrary
+ } else if ProtectedData.holdsWorkKeptInACache(path) {
+ .holdsWorkKeptInACache
} else {
// `/Users/Shared` belongs to every account on the Mac, and the other accounts' apps are not known here.
HoldBack.seen(in: contents) ?? (location.kind == .sharedFolder ? .sharedWithEveryone : nil)
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift
index 40712aac..5deb509a 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift
@@ -366,6 +366,15 @@ struct OrphanScannerTests {
#expect(items.first?.leftAlone == .holdsALibrary)
}
+ @Test func anOrphanedCacheThatKeepsAnEditorsLocalHistorySaysSo() async throws {
+ let directory = try TemporaryDirectory()
+ try directory.file("home/Library/Caches/org.example.editor/LocalHistory/changes.storageData")
+
+ let items = await scanner(in: directory).scan(installedApps: installed).groups.flatMap(\.items)
+
+ #expect(items.map(\.leftAlone) == [.holdsWorkKeptInACache])
+ }
+
/// An app that is gone can leave its wallet behind in its container, and `RemovalGuard` refuses the
/// container around it.
@Test func anOrphanedFolderThatHoldsAProtectedWalletSaysSo() async throws {