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
Take what was refused out of the selection that travels
Țugui Dragoșca290a118e44
diff --git a/Packages/PeelCore/Sources/PeelCore/Removal/CarriedSelection.swift b/Packages/PeelCore/Sources/PeelCore/Removal/CarriedSelection.swiftindex 34de1204..dce2f33a 100644--- a/Packages/PeelCore/Sources/PeelCore/Removal/CarriedSelection.swift+++ b/Packages/PeelCore/Sources/PeelCore/Removal/CarriedSelection.swift@@ -57,6 +57,17 @@ public struct CarriedSelection: Sendable {public var result: TrashResult {TrashResult(trashed: moved.flatMap(\.result.trashed), failures: moved.flatMap(\.result.failures))}++ /// What each part's tool refused for the item itself, which would be refused again as it is now, so it+ /// leaves the selection.+ public var refused: [Part] {+ moved.compactMap { part, result in+ let urls = Set(result.failures.filter(\.reason.isAboutTheItem).map(\.url))+ let sizes = part.sizes.filter { urls.contains($0.key) }+ guard !sizes.isEmpty else { return nil }+ return Part(page: part.page, title: part.title, source: part.source, sourceKey: part.sourceKey, sizes: sizes)+ }+ }}/// The pages seen so far, in the order they were first seen.diff --git a/Packages/PeelCore/Sources/PeelCore/Removal/TrashService.swift b/Packages/PeelCore/Sources/PeelCore/Removal/TrashService.swiftindex 17d4b479..59bfb68a 100644--- a/Packages/PeelCore/Sources/PeelCore/Removal/TrashService.swift+++ b/Packages/PeelCore/Sources/PeelCore/Removal/TrashService.swift@@ -93,6 +93,16 @@ public struct TrashFailure: Sendable, Hashable {}extension TrashFailure.Reason {+ /// Whether the refusal is about the item, which as it is now would be refused again, rather than about Peel's own+ /// state: History it cannot read, or the helper it needs.+ public var isAboutTheItem: Bool {+ switch self {+ case .historyUnreadable, .needsHelper: false+ case .guarded, .changedSinceScan, .claimedSinceScan, .lastCopy, .notPermitted, .locked, .movedWithoutATrace,+ .somethingElseMoved, .heldOpen, .failed: true+ }+ }+/// A fixed word for the reason, which the refusal log stores. It does not change with the text on screen, so/// an old record still reads.public var name: String {diff --git a/Packages/PeelCore/Tests/PeelCoreTests/CarriedSelectionTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/CarriedSelectionTests.swiftindex 52bfe9f2..5ea4fb06 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/CarriedSelectionTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/CarriedSelectionTests.swift@@ -127,6 +127,27 @@ struct CarriedSelectionTests {#expect(pass.result.failures.map(\.url.lastPathComponent) == ["ModuleCache"])}+ /// What a part's tool refused for the item itself leaves its selection, so the next Move to Trash, on any page,+ /// does not carry it again. What was refused for Peel's own state stays selected for when that is put right.+ @Test func whatWasRefusedForItselfLeavesTheSelection() async {+ let parts = [part("space", "caches", ["com.apple.akd": 10, "Kept.app": 20, "Gone": 30, "Later": 40])]+ let pass = await CarriedSelection.pass(parts) { part in+ var result = TrashResult()+ for url in part.sizes.keys {+ switch url.lastPathComponent {+ case "com.apple.akd": result.failures.append(TrashFailure(url: url, reason: .heldOpen(by: ["akd"])))+ case "Kept.app": result.failures.append(TrashFailure(url: url, reason: .guarded(.protectedLocation)))+ case "Later": result.failures.append(TrashFailure(url: url, reason: .historyUnreadable))+ default: result.trashed.append(TrashedItem(originalURL: url, trashedURL: url, date: .now))+ }+ }+ return result+ }++ #expect(pass.refused.map(\.page.scope) == ["caches"])+ #expect(Set(pass.refused.flatMap(\.sizes.keys).map(\.lastPathComponent)) == ["com.apple.akd", "Kept.app"])+ }+/// What a pass moved is one History batch, each record under its own part's source and tool, with the size/// its page measured, and none for an item whose size was not known.@Test func whatMovedIsOneBatchWithEachPartsName() async {diff --git a/Peel/Model/SelectionCarrier.swift b/Peel/Model/SelectionCarrier.swiftindex a0309900..c45fd186 100644--- a/Peel/Model/SelectionCarrier.swift+++ b/Peel/Model/SelectionCarrier.swift@@ -123,6 +123,9 @@ final class SelectionCarrier {}history.finish(removal)outcome.report(pass.result, appsToQuit: appsToQuit)+ for part in pass.refused {+ tool(of: part)?.deselect(part)+ }let moved = pass.moved.map(\.part)for name in moved.tools {guard let tool = Tool(rawValue: name) else { continue }diff --git a/SAFETY.md b/SAFETY.mdindex 6b88cd49..87b3562e 100644--- a/SAFETY.md+++ b/SAFETY.md@@ -213,7 +213,8 @@ them moves all of it. Only a page you have opened counts: Developer and Build Artool and project they list, and what they selected on a page you never saw stays where it is. Before anythingmoves, the question lists every page with how much it holds, and each page's part is moved by its own tool, withthat tool's checks at that moment: Developer waits for its app to quit, Space leaves out what an app opened since-is writing to, and Duplicates refuses a copy that changed.+is writing to, and Duplicates refuses a copy that changed. What a tool refuses for the item itself, such as a folder+a program still has open, leaves the selection, so the next Move to Trash on any page does not carry it again.Some things are shown and never removed at all, because the removal cannot be undone: local Time Machinesnapshots are explained, never deleted.