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.

Never select a leftover the guard would refuse for work kept in a cache

Țugui Dragoș6aa962df845b
diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift
index 5663af6a..7c45a426 100644
--- a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift
+++ b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift
@@ -316,6 +316,7 @@ extension HoldBack {
case .holdsALibrary: "holds a photo, music, or video library"
case .holdsAWallet: "holds a wallet or a signing key"
case .holdsKeys: "holds a wallet or a key Peel protects"
+ case .holdsWorkKeptInACache: "holds work an app keeps nowhere else, such as an editor's local history"
case .insideAnotherAppsFolder: "inside another app's folder"
case .beyondTheHelper: "needs an administrator, and Peel's helper may not move it"
case .keptByMacOS: "a cache macOS keeps for itself"
diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift
index 581b5cb8..fac3f567 100644
--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift
@@ -53,6 +53,9 @@ public enum HoldBack: String, Sendable, Hashable {
case holdsAWallet
/// A wallet or a key `ProtectedData` names is inside, and `RemovalGuard` refuses to move the folder around it.
case holdsKeys
+ /// Work kept nowhere else is inside a cache folder, such as an editor's local history of the person's files, and
+ /// `RemovalGuard` refuses to move the folder around it (`ProtectedData.holdsWorkKeptInACache`).
+ case holdsWorkKeptInACache
/// Claimed on the app's name (or an identifier that is only a word), inside a folder that belongs to another
/// installed app or to Apple. It is probably the other app's data about this one, as a documentation browser
/// or a controller app keeps.
@@ -79,7 +82,8 @@ public enum HoldBack: String, Sendable, Hashable {
/// True when the item cannot be selected at all, rather than only left unselected: the guard or the helper
/// would refuse to move it.
public var cannotBeMoved: Bool {
- self == .holdsDocuments || self == .holdsALibrary || self == .holdsKeys || self == .beyondTheHelper
+ self == .holdsDocuments || self == .holdsALibrary || self == .holdsKeys || self == .holdsWorkKeptInACache
+ || self == .beyondTheHelper
|| self == .holdsAnExclusion
}
diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverScanner.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverScanner.swift
index 0a13a209..b52bf734 100644
--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverScanner.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverScanner.swift
@@ -348,6 +348,8 @@ public struct LeftoverScanner: Sendable {
.holdsDocuments
} else if ProtectedData.holdsALibrary(url.path(percentEncoded: false)) {
.holdsALibrary
+ } else if ProtectedData.holdsWorkKeptInACache(url.path(percentEncoded: false)) {
+ .holdsWorkKeptInACache
} else if contents?.couldNotBeRead == true {
.couldNotBeRead
} else if let contents {
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift
index ea3ec45b..ad6f72fd 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift
@@ -385,6 +385,22 @@ struct LeftoverScannerTests {
#expect(try #require(emptied.leftovers.first { $0.kind == .containers }).match.isRecommended)
}
+ @Test func aCacheThatKeepsAnEditorsLocalHistoryIsShownAndLeftAlone() async throws {
+ let directory = try TemporaryDirectory()
+ try directory.file("home/Library/Caches/net.example.client/LocalHistory/changes.storageData")
+ try directory.file("home/Library/Caches/net.example.client/index/files.dat")
+
+ let scan = await LeftoverScanner(environment: environment(in: directory)).scan(
+ tunewell,
+ installedApps: [tunewell]
+ )
+
+ let cache = try #require(scan.leftovers.first { $0.kind == .caches })
+ #expect(cache.match.heldBack == .holdsWorkKeptInACache)
+ #expect(cache.match.heldBack?.cannotBeMoved == true)
+ #expect(!cache.match.isRecommended)
+ }
+
@Test(.permissionsHold) func reportsUnreadableLocations() async throws {
let directory = try TemporaryDirectory()
try directory.file("home/Library/Logs/Tunewell/log.txt")
diff --git a/Peel/Views/Presentation.swift b/Peel/Views/Presentation.swift
index db1bb2fa..352dd9fd 100644
--- a/Peel/Views/Presentation.swift
+++ b/Peel/Views/Presentation.swift
@@ -221,6 +221,8 @@ extension HoldBack {
"Not selected: a wallet or a signing key is inside. Once the Trash is emptied, what it opens is gone for good unless you have a backup."
case .holdsKeys:
"Left alone: a wallet or a key Peel protects is inside, so Peel leaves this folder where it is."
+ case .holdsWorkKeptInACache:
+ "Peel won’t move this: an app keeps work inside that exists nowhere else, such as an editor’s local history."
case .insideAnotherAppsFolder:
"Not selected: only the name matches, and it sits inside a folder that belongs to macOS or to another installed app, which may be keeping it for itself."
case .beyondTheHelper: