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
Say in peel history that some removals left items behind
Țugui Dragoșc95b8dd3a776
diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Commands/HistoryCommands.swift b/Packages/PeelCore/Sources/PeelCommandLine/Commands/HistoryCommands.swiftindex 3bbe7403..66782fb7 100644--- a/Packages/PeelCore/Sources/PeelCommandLine/Commands/HistoryCommands.swift+++ b/Packages/PeelCore/Sources/PeelCommandLine/Commands/HistoryCommands.swift@@ -212,10 +212,20 @@ struct HistoryCommand: AsyncParsableCommand {Output.table(Self.rows(for: batches))}// Said where the list reaches History's oldest removal, below which the older ones would be.- if outcome.noLongerListed > 0, batches.count == all.count {+ let reachesTheEnd = batches.count == all.count+ if outcome.noLongerListed > 0, reachesTheEnd {let removals = Output.count(outcome.noLongerListed, "older removal", "older removals")Output.note("History no longer lists \(removals). What was moved is still in the Trash unless you emptied it.")}+ // What stayed is listed apart, by --refused, so the list says how many removals of its time left something.+ let since = reachesTheEnd ? nil : batches.last?.date+ let stayed = RefusalRecord.grouped(await refusals.load().records ?? []).filter { removal in+ since.map { removal.date >= $0 } ?? true+ }+ if !stayed.isEmpty {+ let removals = Output.count(stayed.count, "removal also has", "removals also have")+ Output.note("\(removals) items that stayed. See `peel history --refused`.")+ }if let problem = outcome.problem {Output.note(problem.summary)}diff --git a/Packages/PeelCore/Tests/PeelCoreTests/HistoryCommandTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/HistoryCommandTests.swiftindex ce7de7f8..804b1797 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/HistoryCommandTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/HistoryCommandTests.swift@@ -282,6 +282,36 @@ struct HistoryCommandTests {#expect(try await printed(["history"], from: logs) == "History lists no removals.\n")}+ /// The list of what moved says how many removals also left items where they were, which `--refused` lists; a+ /// list that `--limit` cuts short counts only those since its oldest removal.+ @Test func saysHowManyRemovalsAlsoHaveItemsThatStayed() async throws {+ let directory = try TemporaryDirectory()+ let logs = logs(in: directory)+ let earlier = Date.now.addingTimeInterval(-120)+ func moved(_ name: String, at date: Date) -> RemovalRecord {+ RemovalRecord(+ batch: UUID(),+ item: TrashedItem(+ originalURL: URL(filePath: "/Users/me/\(name)"),+ trashedURL: URL(filePath: "/Users/me/.Trash/\(name)"),+ date: date+ ),+ size: 1,+ source: "Editor",+ tool: "applications"+ )+ }+ _ = await logs.removals.add([moved("old.bin", at: earlier)])+ _ = await logs.removals.add([moved("new.bin", at: .now)])+ let stayed = TrashFailure(url: URL(filePath: "/Users/me/kept.bin"), reason: .guarded(.excluded))+ await logs.refusals.add([stayed], source: "Editor", tool: "applications", date: earlier)+ let note = "1 removal also has items that stayed. See `peel history --refused`.\n"++ #expect(try await noted(["history"], from: logs) == note)+ #expect(try await noted(["history", "--json"], from: logs) == note)+ #expect(try await noted(["history", "--limit", "1"], from: logs).isEmpty)+ }+/// `--limit` is what the command prints, in the table and in `--json` alike, and 20 without it.@Test func showsAtMostWhatWasAskedFor() async throws {let directory = try TemporaryDirectory()