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.

Don't call an emptied History one Peel never wrote to

Țugui Dragoșf81e65658322
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index 423b500b..9e8f6310 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -95145,6 +95145,113 @@
}
}
},
+ "No Removals" : {
+ "comment" : "History’s title when it lists nothing although Peel has moved something before, since Put Back and Forget can empty it. Like Finder’s “No Recents”.",
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Žádná odstranění"
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Keine Einträge"
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "No hay eliminaciones"
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Aucune suppression"
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nessuna rimozione"
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "ゴミ箱に入れた記録はありません"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "제거 내역 없음"
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Geen verwijderingen"
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Brak przeniesień do Kosza"
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nenhuma Remoção"
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nicio eliminare"
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Нет удалений"
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Inga borttagningar"
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Kaldırma İşlemi Yok"
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Немає вилучень"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "无移除记录"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "沒有移除記錄"
+ }
+ }
+ }
+ },
"No Results" : {
"localizations" : {
"cs" : {
diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Commands/HistoryCommands.swift b/Packages/PeelCore/Sources/PeelCommandLine/Commands/HistoryCommands.swift
index 0d5bb9c3..3bbe7403 100644
--- a/Packages/PeelCore/Sources/PeelCommandLine/Commands/HistoryCommands.swift
+++ b/Packages/PeelCore/Sources/PeelCommandLine/Commands/HistoryCommands.swift
@@ -205,7 +205,9 @@ struct HistoryCommand: AsyncParsableCommand {
)
})
} else if batches.isEmpty {
- Output.line("Peel hasn't moved anything to the Trash yet.")
+ // Put Back and Forget can empty a History Peel did write to.
+ let hasMoved = outcome.noLongerListed > 0 || RemovalTotals.read(beside: log.url).items > 0
+ Output.line(hasMoved ? "History lists no removals." : "Peel hasn't moved anything to the Trash yet.")
} else {
Output.table(Self.rows(for: batches))
}
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/HistoryCommandTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/HistoryCommandTests.swift
index 6e1aaade..ce7de7f8 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/HistoryCommandTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/HistoryCommandTests.swift
@@ -272,6 +272,16 @@ struct HistoryCommandTests {
#expect(try await noted(["history", "--limit", "\(listed - 1)"], from: logs).isEmpty)
}
+ /// A History emptied by Put Back or Forget is not called one Peel never wrote to.
+ @Test func anEmptiedHistoryIsNotCalledNeverUsed() async throws {
+ let directory = try TemporaryDirectory()
+ let logs = logs(in: directory)
+ let added = await logs.removals.add([try removal(in: directory).record])
+ _ = await logs.removals.remove(Set(try #require(added.records).map(\.id)))
+
+ #expect(try await printed(["history"], from: logs) == "History lists no removals.\n")
+ }
+
/// `--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()
diff --git a/Peel/Views/History/HistoryList.swift b/Peel/Views/History/HistoryList.swift
index ed6cbb67..4726a615 100644
--- a/Peel/Views/History/HistoryList.swift
+++ b/Peel/Views/History/HistoryList.swift
@@ -4,6 +4,7 @@ import SwiftUI
struct HistoryList: View {
@Environment(RemovalHistoryStore.self) private var history
+ @Environment(LifetimeStats.self) private var stats
@State private var isReloading = false
@State private var searchText = ""
/// What the search found, worked out off the main actor, since a removal's key names every item in it. Kept while
@@ -89,8 +90,9 @@ struct HistoryList: View {
if !history.hasLoaded {
ProgressView()
} else if history.isKnownEmpty {
+ // Put Back and Forget can empty a History Peel did write to.
ContentUnavailableView(
- "Nothing Removed Yet",
+ stats.hasCleaned || history.noLongerListed > 0 ? "No Removals" : "Nothing Removed Yet",
systemImage: "clock.arrow.circlepath",
description: Text("What you move to the Trash with Peel shows up here, and can be put back while it’s still in the Trash.")
)