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
Exit 1 from peel restore when an item waits on a disk not connected
Țugui Dragoș39f5171a9edc
diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Commands/HistoryCommands.swift b/Packages/PeelCore/Sources/PeelCommandLine/Commands/HistoryCommands.swiftindex f231030e..ec860cff 100644--- a/Packages/PeelCore/Sources/PeelCommandLine/Commands/HistoryCommands.swift+++ b/Packages/PeelCore/Sources/PeelCommandLine/Commands/HistoryCommands.swift@@ -442,6 +442,7 @@ struct RestoreCommand: AsyncParsableCommand {for (record, failure) in failures {Output.note("Couldn't put \(Output.plain(Output.path(record.originalURL))) back: \(failure.summary)")}- try Cleanup.end(failed: !failures.isEmpty || !refused.isEmpty, recorded: forgotten)+ let stayed = !failures.isEmpty || !refused.isEmpty || !waiting.isEmpty || !notKnown.isEmpty+ try Cleanup.end(failed: stayed, recorded: forgotten)}}diff --git a/Packages/PeelCore/Tests/PeelCoreTests/HistoryCommandTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/HistoryCommandTests.swiftindex 23b40c35..3da19249 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/HistoryCommandTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/HistoryCommandTests.swift@@ -622,6 +622,30 @@ struct HistoryCommandTests {== "Peel can't look in the Trash right now, so it can't say what could go back.")}+ @Test func aRestoreFailsWhenAnItemWaitsOnADiskThatIsNotConnected() async throws {+ let directory = try TemporaryDirectory()+ let logs = logs(in: directory)+ let taken = try removal(in: directory)+ let waiting = RemovalRecord(+ batch: taken.record.batch,+ item: TrashedItem(+ originalURL: URL(filePath: "/Volumes/org.example.Missing/Report.pdf"),+ trashedURL: URL(filePath: "/Volumes/org.example.Missing/.Trashes/501/Report.pdf"),+ date: .now+ ),+ size: 10, source: "Editor", tool: "applications"+ )+ _ = await logs.removals.add([taken.record, waiting])++ let dry = try await restoring(taken.record, "--dry-run", from: logs, in: directory)+ #expect(dry.failure == nil)++ let real = try await restoring(taken.record, "-y", from: logs, in: directory)+ #expect(real.said.contains("Put 1 item back."))+ #expect(real.said.contains("1 item is on a disk that isn't connected."))+ #expect(real.failure != nil)+ }+@Test func saysSoWhenEverythingLeftIsRefused() async throws {let directory = try TemporaryDirectory()let logs = logs(in: directory)