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.

An exclusion inside never hides why a folder can't move

Țugui Dragoș72a8a0b9d0ab
diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift
index 60a1f40f..2aa9a593 100644
--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift
@@ -179,9 +179,11 @@ public struct Leftover: Sendable, Hashable, Identifiable {
public var id: URL { url }
- /// Returns the same leftover, held back for `reason`: shown, but never selected.
+ /// Returns the same leftover, held back for `reason`: shown, but never selected. A reason that already blocks
+ /// the move stays, since it outranks one that only leaves the item unselected.
func heldBack(_ reason: HoldBack) -> Leftover {
- Leftover(
+ guard match.heldBack?.cannotBeMoved != true else { return self }
+ return Leftover(
url: url, kind: kind, match: match.forReview(reason), size: size, isMeasured: isMeasured,
requiresPrivileges: requiresPrivileges, holdsDamagedSettings: holdsDamagedSettings
)
@@ -212,8 +214,7 @@ public struct LeftoverScan: Sendable {
leftovers: leftovers.map { leftover in
let heldBack = leftover.match.heldBack
guard
- leftover.requiresPrivileges,
- heldBack?.cannotBeMoved != true, heldBack != .holdsAnExclusion,
+ leftover.requiresPrivileges, heldBack != .holdsAnExclusion,
reach.isBeyond(leftover.url, leaving: app)
else { return leftover }
return leftover.heldBack(.beyondTheHelper)
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift
index 4c6307a5..4e5dd3f9 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift
@@ -614,6 +614,23 @@ struct LeftoverScannerTests {
#expect(!found.isMeasured)
}
+ /// Something excluded inside only leaves a folder unselected, so it never takes the place of a reason that blocks
+ /// the move: the row still says the folder cannot be moved at all.
+ @Test func anExclusionInsideNeverHidesAReasonThatBlocksTheMove() async throws {
+ let directory = try TemporaryDirectory()
+ try directory.file("home/Library/Application Support/Tunewell/Libraries/Main.musiclibrary/Library.musicdb")
+ try directory.file("home/Library/Application Support/Tunewell/logs/today.log")
+ let folder = directory.url.appending(path: "home/Library/Application Support/Tunewell")
+ let exclusions = Exclusions(paths: [folder.appending(path: "logs")])
+
+ let scanner = LeftoverScanner(environment: environment(in: directory), exclusions: exclusions)
+ let scan = await scanner.scan(tunewell, installedApps: [tunewell])
+
+ let found = try #require(scan.leftovers.first { $0.url.lastPathComponent == "Tunewell" })
+ #expect(found.match.heldBack == .holdsALibrary)
+ #expect(found.match.heldBack?.cannotBeMoved == true)
+ }
+
/// An exclusion inside replaces `notMeasured` as the reason, but the folder's size stays unknown, not zero.
@Test func aFolderHoldingAnExclusionKeepsASizeNobodyKnows() async throws {
let directory = try TemporaryDirectory()