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
Tell what a Put Back left wherever the person is, and name what a stop cuts short
Țugui Dragoș980924a53414
diff --git a/ARCHITECTURE.md b/ARCHITECTURE.mdindex c8473d44..71b551e9 100644--- a/ARCHITECTURE.md+++ b/ARCHITECTURE.md@@ -174,10 +174,10 @@ the Homebrew page's uninstall and cleanups are Homebrew's own.`RemovalTotals`), so the app and `peel` count alike.- Each item is also written down the moment it moves, and what the helper moves as soon as it answers eachrequest (`removals.journal`, through `RemovalJournal`), so what a removal moved before it was cut short reaches- History the next time History is read, as an interrupted removal, or as what it was when History couldn't write- it, since its line then keeps the record (`RemovalJournal.keep`). A removal recorded a part at a time writes- its batch and the part on each line (`RecordedRemoval`), so what a part left there joins that removal under the- part's name. Quitting the app waits for a removal until History has it (`QuitGuard`), as `peel` carries on+ History the next time History is read, as what it was when History couldn't write it, since its line then keeps+ the record (`RemovalJournal.keep`), and otherwise under the name its page gave it: each line carries its batch+ and its part (`RecordedRemoval`), so what a part left there joins that removal under the part's name. Only a+ removal from `peel`, or a line without a part, comes back as an interrupted removal. Quitting the app waits for a removal until History has it (`QuitGuard`), as `peel` carries onthrough Control-C (`Uninterrupted`).- While History cannot be read nothing moves (`RemovalLog.canBeRead`, asked by `TrashService` before a removal)until Start Over, on the History page, sets the unreadable file aside, and while it cannot be written, its folderdiff --git a/Packages/PeelCore/Sources/PeelCore/Removal/RemovalHistory.swift b/Packages/PeelCore/Sources/PeelCore/Removal/RemovalHistory.swiftindex 2c0ad521..2c732b87 100644--- a/Packages/PeelCore/Sources/PeelCore/Removal/RemovalHistory.swift+++ b/Packages/PeelCore/Sources/PeelCore/Removal/RemovalHistory.swift@@ -132,6 +132,12 @@ public struct TrashedDisk: Sendable, Codable, Hashable {public struct MountedDisks: Sendable {private let places: [String: String]+ /// The disks mounted now, read off the main actor: macOS may wait on a disk that doesn't answer.+ @concurrent+ public static func read() async -> MountedDisks {+ now()+ }+public static func now() -> MountedDisks {let key = URLResourceKey.volumeUUIDStringKeylet volumes = FileManager.default.mountedVolumeURLs(includingResourceValuesForKeys: [key], options: []) ?? []diff --git a/Packages/PeelCore/Sources/PeelCore/Removal/RemovalStanding.swift b/Packages/PeelCore/Sources/PeelCore/Removal/RemovalStanding.swiftindex 7d12896b..6d5a19f3 100644--- a/Packages/PeelCore/Sources/PeelCore/Removal/RemovalStanding.swift+++ b/Packages/PeelCore/Sources/PeelCore/Removal/RemovalStanding.swift@@ -12,6 +12,7 @@ public struct RemovalStanding: Sendable {public private(set) var restorableSize = SizeTotal([])/// How many records have left the Trash.public private(set) var missingCount = 0+ private var places: [RemovalRecord.ID: URL] = [:]/// Reads the disk off the main actor.@concurrent@@ -34,9 +35,11 @@ public struct RemovalStanding: Sendable {away.insert(record.id)continue}- let place = record.located(on: disks).standing+ let located = record.located(on: disks)+ let place = located.standingif place == .inTheTrash {inTrash.insert(record.id)+ places[record.id] = located.trashedURLrestorableRecords.append(record)} else if place == .notKnown {notKnown.insert(record.id)@@ -48,6 +51,11 @@ public struct RemovalStanding: Sendable {restorableSize = restorableRecords.totalSize}+ /// Where `record`'s item is in the Trash now: its disk may be mounted at another place than when it moved.+ public func place(of record: RemovalRecord) -> URL {+ places[record.id] ?? record.trashedURL+ }+/// The records among `records` that have left the Trash.public func missing(among records: [RemovalRecord]) -> [RemovalRecord] {records.filter { !inTrash.contains($0.id) && !away.contains($0.id) && !notKnown.contains($0.id) }diff --git a/Packages/PeelCore/Tests/PeelCoreTests/RemovalStandingTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/RemovalStandingTests.swiftindex 8f0c2a66..3cb53518 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/RemovalStandingTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/RemovalStandingTests.swift@@ -51,6 +51,8 @@ struct RemovalStandingTests {try disk?.remount(at: directory.url.appending(path: "Renamed", directoryHint: .isDirectory))let elsewhere = RemovalStanding([moved])+ let renamed = directory.url.appending(path: "Renamed/.Trashes/\(getuid())/report.txt")+ #expect(PathPattern.comparablePath(of: elsewhere.place(of: moved)) == PathPattern.comparablePath(of: renamed))disk = nillet other = try ScratchVolume(fileSystem: "MS-DOS FAT32", mountedAt: place)try FileManager.default.createDirectory(at: trash, withIntermediateDirectories: true)diff --git a/Peel/Model/BulkRemovalPlan.swift b/Peel/Model/BulkRemovalPlan.swiftindex 68990259..ccfe2dff 100644--- a/Peel/Model/BulkRemovalPlan.swift+++ b/Peel/Model/BulkRemovalPlan.swift@@ -189,7 +189,7 @@ final class BulkRemovalPlan {}/// Up to three app names, or a count in English that History shows in the user's language through the key.- private func part(naming named: [InstalledApp]) -> RemovalPart {+ func part(naming named: [InstalledApp]) -> RemovalPart {let named = named.isEmpty ? apps : namedlet tool = Tool.applications.rawValueguard named.count > 3 else {diff --git a/Peel/Model/RemovalHistoryStore.swift b/Peel/Model/RemovalHistoryStore.swiftindex a3047775..9c6a95a7 100644--- a/Peel/Model/RemovalHistoryStore.swift+++ b/Peel/Model/RemovalHistoryStore.swift@@ -176,8 +176,6 @@ final class RemovalHistoryStore {/// sits in many batches.var selectedIDs: Set<RemovalRecord.ID> = []var failures: [RemovalRecord.ID: RestoreFailure] = [:]- /// Counts the Put Backs History's page tells, so one that ends as the one before is told again.- private(set) var toldPutBacks = 0/// Counts the times a removal's page has to look in the Trash again: History read again, by Reload or as Peel came/// forward, and a Put Back that brought something back, whatever History could write of it.private(set) var trashLooks = 0@@ -340,6 +338,18 @@ final class RemovalHistoryStore {finish(removal)}+ /// Runs `move`, whose items the journal writes down under this name, so a removal a stop leaves unrecorded comes+ /// back in History as what it was and not as an interrupted removal.+ func moving<Answer>(_ part: RemovalPart, _ move: () async -> Answer) async -> Answer {+ await RecordedRemoval.$current.withValue(RecordedRemoval(batch: UUID(), part: part)) { await move() }+ }++ func moving<Answer>(+ tool: Tool, source: String, sourceKey: String? = nil, _ move: () async -> Answer+ ) async -> Answer {+ await moving(RemovalPart(source: source, sourceKey: sourceKey, tool: tool.rawValue), move)+ }+/// Records in History what one part of `removal` moved, and what it refused.func record(_ result: TrashResult,@@ -405,11 +415,7 @@ final class RemovalHistoryStore {func undoLastRemoval() async {guard let undoable, !isRestoring, mayMove else { return }self.undoable = nil- let stayed = await restore(undoable.records, canUseHelper: canUseHelper, tellingThePage: false)- guard !stayed.isEmpty else { return }- outcome?.reportPutBack(stayed.map {- RemovalOutcome.PutBackFailure(url: $0.record.originalURL, failure: $0.failure)- }, of: undoable.records.count)+ let stayed = await restore(undoable.records, canUseHelper: canUseHelper)// What stayed for a reason that can pass, such as the helper or something in its place, can be asked again.let again = stayed.filter { !$0.failure.isFinal }.map(\.record)if !again.isEmpty { self.undoable = (again, undoable.title) }@@ -479,11 +485,11 @@ final class RemovalHistoryStore {return (batches, searchKeys)}- /// Puts `records` back and answers what stayed, each with why. History's page shows the reasons- /// (`tellingThePage`); an Undo, asked from any page, has them told by the app instead.+ /// Puts `records` back and answers what stayed, each with why. What stayed is told by the app wherever the person+ /// is by then, since a Put Back can outlast the page that asked, and each reason stays under its row.@discardableResultfunc restore(- _ records: [RemovalRecord], canUseHelper: Bool, tellingThePage: Bool = true+ _ records: [RemovalRecord], canUseHelper: Bool) async -> [(record: RemovalRecord, failure: RestoreFailure)] {// One restore at a time, however often it is asked for: two rounds over the same records would each// report the items the other put back as already there.@@ -495,7 +501,7 @@ final class RemovalHistoryStore {var problems: [RemovalRecord.ID: RestoreFailure] = [:]var stayed: [(record: RemovalRecord, failure: RestoreFailure)] = []let ordered = records.inPutBackOrder- let disks = MountedDisks.now()+ let disks = await MountedDisks.read()let answers = await restoring(ordered.map { $0.located(on: disks).trashedItem }, canUseHelper)for (record, answer) in zip(ordered, answers) {if let failure = answer {@@ -505,9 +511,13 @@ final class RemovalHistoryStore {restored.insert(record.id)}}- if tellingThePage {- failures = problems- toldPutBacks += 1+ for record in ordered {+ failures[record.id] = problems[record.id]+ }+ if !stayed.isEmpty {+ outcome?.reportPutBack(stayed.map {+ RemovalOutcome.PutBackFailure(url: $0.record.originalURL, failure: $0.failure)+ }, of: records.count)}selectedIDs.subtract(restored)if !restored.isEmpty {diff --git a/Peel/Views/AppDetailView.swift b/Peel/Views/AppDetailView.swiftindex 9284e718..b02a4aa5 100644--- a/Peel/Views/AppDetailView.swift+++ b/Peel/Views/AppDetailView.swift@@ -520,7 +520,9 @@ struct AppDetailView: View {// The one step that goes before the move: `tccutil` only finds an app that is still in its place.let service = TrashService(exclusions: ExclusionsStore.shared.exclusions)let privacy = await PrivacyReset.reset(resetting(request.urls), beforeMovingWith: service)- let result = await plan.move(request)+ let result = await history.moving(tool: .applications, source: plan.app.name) {+ await plan.move(request)+ }let keptItsFiles = plan.uninstallation?.keptItsFiles(after: result, selection: request.urls) == truelet left = plan.uninstallation?.leftForAnAdministrator(after: result) ?? []await LeftForAnAdministrator().record(left)diff --git a/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift b/Peel/Views/BackgroundItems/BackgroundItemDetailView.swiftindex 6f428e92..eaf555f2 100644--- a/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift+++ b/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift@@ -277,8 +277,10 @@ struct BackgroundItemDetailView: View {if let plist = item.plistURL {sizes[plist] = await FileSize.reclaimableSize(of: plist)}- await backgroundItems.perform(.moveToTrash, on: item) { result in- await history.record(result, tool: .backgroundItems, source: item.label, sizes: sizes)+ await history.moving(tool: .backgroundItems, source: item.label) {+ await backgroundItems.perform(.moveToTrash, on: item) { result in+ await history.record(result, tool: .backgroundItems, source: item.label, sizes: sizes)+ }}}}diff --git a/Peel/Views/History/HistoryDetailView.swift b/Peel/Views/History/HistoryDetailView.swiftindex b23fc0b7..d4ff12e9 100644--- a/Peel/Views/History/HistoryDetailView.swift+++ b/Peel/Views/History/HistoryDetailView.swift@@ -5,17 +5,10 @@ import SwiftUIstruct HistoryDetailView: View {@Environment(RemovalHistoryStore.self) private var history@Environment(HelperModel.self) private var helper- @Environment(\.openSettings) private var openSettings/// Nil until the disk has answered. An empty value would show every record as gone from the Trash for a/// moment, and offer to forget records that are still there.@State private var standing: RemovalStanding?@State private var isAskingToForget = false- /// The alert after a Put Back that left items behind. Its reasons stay under the rows once it is closed.- @State private var isShowingFailures = false- /// This batch's items that stayed in the Trash, in the order the page lists them.- @State private var failures: [(record: RemovalRecord, failure: RestoreFailure)] = []- /// How many items the last Put Back asked for, for the alert's title.- @State private var askedToPutBack = 0let batch: RemovalBatch/// The id of the page's task: the batch, and each time History was read again. When either changes, the page@@ -58,7 +51,6 @@ struct HistoryDetailView: View {) {guard let standing else { return }let selected = standing.selected(among: batch.records, in: history.selectedIDs)- askedToPutBack = selected.countTask { await history.restore(selected, canUseHelper: helper.canAct) }}}@@ -70,32 +62,6 @@ struct HistoryDetailView: View {guard !Task.isCancelled else { return }self.standing = standing}- .task(id: batch.id) {- // Failures belong to the batch they happened in, so another batch's page starts without them. Keyed to- // the batch alone: a Put Back that partly worked changes the batch's records, and the alert that- // reports the rest must stay.- history.failures = [:]- }- .onChange(of: history.toldPutBacks) {- failures = batch.records.compactMap { record in history.failures[record.id].map { (record, $0) } }- isShowingFailures = !failures.isEmpty- }- .alert(- Text(verbatim: RestoreFailure.title(stayed: failures.count, of: askedToPutBack)),- isPresented: $isShowingFailures- ) {- if failures.contains(where: { $0.failure == .needsAppManagement }) {- Button("Open System Settings") { NSWorkspace.shared.open(AppManagement.settingsURL) }- }- if failures.contains(where: { $0.failure == .needsHelper }) {- Button("Open Peel Settings") { SettingsPane.helper.open(with: openSettings) }- }- Button("Copy Details") { copyFailureDetails() }- Button("OK", role: .cancel) {}- .keyboardShortcut(.defaultAction)- } message: {- failureMessage- }}@ViewBuilder@@ -149,6 +115,7 @@ struct HistoryDetailView: View {history: history,record: record,place: place(of: record, in: standing),+ trashedURL: standing.place(of: record),failure: history.failures[record.id],isSelected: history.isSelected(record),isFirst: record.id == batch.records.first?.id@@ -202,27 +169,6 @@ struct HistoryDetailView: View {return .gone}- /// The alert's message: the first few items that couldn't be put back, each with its own reason, since items- /// can fail for different reasons, and how many more there are.- private var failureMessage: Text {- let failures = failures- var lines = failures.prefix(RemovalFailureAlert.mostListed).map {- "\($0.record.originalURL.abbreviatedPath)\n\($0.failure.explanation)"- }- let rest = failures.count - lines.count- if rest > 0 {- lines.append(String(inflecting: "And ^[\(rest) more item](inflect: true)."))- }- return Text(verbatim: lines.joined(separator: "\n\n"))- }-- /// Copies every item with its full path, since the alert lists only the first few and its text can't be- /// selected.- private func copyFailureDetails() {- let lines = failures.map { "\($0.record.originalURL.path(percentEncoded: false))\n\($0.failure.explanation)" }- NSPasteboard.general.clearContents()- NSPasteboard.general.setString(lines.joined(separator: "\n\n"), forType: .string)- }}private struct RestoreBar: View {@@ -294,6 +240,8 @@ private struct HistoryRecordRow: View {let history: RemovalHistoryStorelet record: RemovalRecordlet place: RecordPlace+ /// Where the item is now, which is not where it went when its disk is mounted at another place.+ let trashedURL: URL/// Why the last Put Back left this item in the Trash, said under it.let failure: RestoreFailure?let isSelected: Bool@@ -319,7 +267,7 @@ private struct HistoryRecordRow: View {.contextMenu {if place == .inTrash {Button("Show in Finder", systemImage: "folder") {- NSWorkspace.shared.activateFileViewerSelecting([record.trashedURL])+ NSWorkspace.shared.activateFileViewerSelecting([trashedURL])}}Button("Copy Path", systemImage: "doc.on.doc") {diff --git a/Peel/Views/Homebrew/ForgetCasksDialog.swift b/Peel/Views/Homebrew/ForgetCasksDialog.swiftindex 6905a2d8..a0354dc0 100644--- a/Peel/Views/Homebrew/ForgetCasksDialog.swift+++ b/Peel/Views/Homebrew/ForgetCasksDialog.swift@@ -33,13 +33,18 @@ struct ForgetCasksDialog: ViewModifier {private func forget(_ casks: [HomebrewPackage]) {Task {- let result = await homebrew.forget(casks) { result in- var sizes: [URL: Int64] = [:]- for item in result.trashed {- sizes[item.originalURL] = await FileSize.reclaimableSize(of: item.trashedURL)+ let asked = HomebrewLibrary.source(of: casks, after: TrashResult())+ let result = await history.moving(tool: .homebrew, source: asked.source, sourceKey: asked.key) {+ await homebrew.forget(casks) { result in+ var sizes: [URL: Int64] = [:]+ for item in result.trashed {+ sizes[item.originalURL] = await FileSize.reclaimableSize(of: item.trashedURL)+ }+ let named = HomebrewLibrary.source(of: casks, after: result)+ await history.record(+ result, tool: .homebrew, source: named.source, sourceKey: named.key, sizes: sizes+ )}- let named = HomebrewLibrary.source(of: casks, after: result)- await history.record(result, tool: .homebrew, source: named.source, sourceKey: named.key, sizes: sizes)}if let result { outcome.report(result) }}diff --git a/Peel/Views/MultipleAppsView.swift b/Peel/Views/MultipleAppsView.swiftindex d0b6e4f3..4509aee6 100644--- a/Peel/Views/MultipleAppsView.swift+++ b/Peel/Views/MultipleAppsView.swift@@ -392,7 +392,7 @@ struct MultipleAppsView: View {// place.let service = TrashService(exclusions: ExclusionsStore.shared.exclusions)let privacy = await PrivacyReset.reset(resetting(request.urls), beforeMovingWith: service)- let result = await plan.move(request)+ let result = await history.moving(plan.part(naming: [])) { await plan.move(request) }let kept = plan.bulk?.appsThatKeptTheirFiles(after: result, selection: request.urls) ?? []let left = plan.bulk?.leftForAnAdministrator(after: result) ?? []await LeftForAnAdministrator().record(left)diff --git a/Peel/Views/Packages/ForgetReceiptDialog.swift b/Peel/Views/Packages/ForgetReceiptDialog.swiftindex 0c4933a4..7ad95bf5 100644--- a/Peel/Views/Packages/ForgetReceiptDialog.swift+++ b/Peel/Views/Packages/ForgetReceiptDialog.swift@@ -17,12 +17,14 @@ struct ForgetReceiptDialog: ViewModifier {.confirmationDialog(Text("Forget the receipt of \(receipt?.identifier ?? "")?"), isPresented: isAsking, presenting: receipt) { receipt inButton("Forget Receipt") {Task {- let result = await forget(receipt) { result in- var sizes: [URL: Int64] = [:]- for item in result.trashed {- sizes[item.originalURL] = await FileSize.reclaimableSize(of: item.trashedURL)+ let result = await history.moving(tool: .packages, source: receipt.identifier) {+ await forget(receipt) { result in+ var sizes: [URL: Int64] = [:]+ for item in result.trashed {+ sizes[item.originalURL] = await FileSize.reclaimableSize(of: item.trashedURL)+ }+ await history.record(result, tool: .packages, source: receipt.identifier, sizes: sizes)}- await history.record(result, tool: .packages, source: receipt.identifier, sizes: sizes)}outcome.report(result)}@@ -87,13 +89,17 @@ struct ForgetReceiptsDialog: ViewModifier {private func forget(_ receipts: [PackageReceipt]) {Task {- let result = await packages.forget(receipts) { result in- var sizes: [URL: Int64] = [:]- for item in result.trashed {- sizes[item.originalURL] = await FileSize.reclaimableSize(of: item.trashedURL)+ let named = PackageLibrary.source(of: receipts)+ let result = await history.moving(tool: .packages, source: named.source, sourceKey: named.key) {+ await packages.forget(receipts) { result in+ var sizes: [URL: Int64] = [:]+ for item in result.trashed {+ sizes[item.originalURL] = await FileSize.reclaimableSize(of: item.trashedURL)+ }+ await history.record(+ result, tool: .packages, source: named.source, sourceKey: named.key, sizes: sizes+ )}- let named = PackageLibrary.source(of: receipts)- await history.record(result, tool: .packages, source: named.source, sourceKey: named.key, sizes: sizes)}outcome.report(result)}diff --git a/Peel/Views/Packages/PackageDetailView.swift b/Peel/Views/Packages/PackageDetailView.swiftindex 02c2612b..a2c5d2b6 100644--- a/Peel/Views/Packages/PackageDetailView.swift+++ b/Peel/Views/Packages/PackageDetailView.swift@@ -116,13 +116,15 @@ struct PackageDetailView: View {) {Button("Move to Trash") {Task {- let result = await packages.removeSelectedItems { result in- await history.record(- result,- tool: .packages,- source: receipt.identifier,- sizes: [URL: Int64](measured: receipt.items.map { ($0.url, $0.size) })- )+ let result = await history.moving(tool: .packages, source: receipt.identifier) {+ await packages.removeSelectedItems { result in+ await history.record(+ result,+ tool: .packages,+ source: receipt.identifier,+ sizes: [URL: Int64](measured: receipt.items.map { ($0.url, $0.size) })+ )+ }}outcome.report(result)}diff --git a/Peel/Views/Plugins/PluginDetailView.swift b/Peel/Views/Plugins/PluginDetailView.swiftindex 5c7d473e..3e6ce129 100644--- a/Peel/Views/Plugins/PluginDetailView.swift+++ b/Peel/Views/Plugins/PluginDetailView.swift@@ -115,13 +115,15 @@ struct PluginDetailView: View {) {Button("Move to Trash") {Task {- let result = await plugins.moveToTrash(plugin) { result in- await history.record(- result,- tool: .plugins,- source: plugin.name,- sizes: [URL: Int64](measured: [(plugin.url, plugin.size)])- )+ let result = await history.moving(tool: .plugins, source: plugin.name) {+ await plugins.moveToTrash(plugin) { result in+ await history.record(+ result,+ tool: .plugins,+ source: plugin.name,+ sizes: [URL: Int64](measured: [(plugin.url, plugin.size)])+ )+ }}outcome.report(result)if !result.trashed.isEmpty {diff --git a/Peel/Views/ResetSheet.swift b/Peel/Views/ResetSheet.swiftindex f99e1d5f..a66033bd 100644--- a/Peel/Views/ResetSheet.swift+++ b/Peel/Views/ResetSheet.swift@@ -39,7 +39,11 @@ struct ResetSheet: View {Button("Reset", role: .destructive) {Task {await QuitGuard.shared.run {- let result = await plan.performReset()+ let result = await history.moving(+ tool: .applications, source: "Reset of \(plan.app.name)", sourceKey: "reset.\(plan.app.name)"+ ) {+ await plan.performReset()+ }if !result.trashed.isEmpty {changedFiles = true}diff --git a/Peel/Views/Settings/SavedSettingsSection.swift b/Peel/Views/Settings/SavedSettingsSection.swiftindex 3777eb8d..0c5b2637 100644--- a/Peel/Views/Settings/SavedSettingsSection.swift+++ b/Peel/Views/Settings/SavedSettingsSection.swift@@ -189,14 +189,17 @@ struct SavedSettingsSection: View {// Measured before the move, since nothing is left at that path after it.let size = await FileSize.reclaimableSize(of: copy.folder)await QuitGuard.shared.run {- let result = await TrashService(exclusions: ExclusionsStore.shared.exclusions).trash([copy.folder])+ let source = "Settings Saved for \(name)"+ let result = await history.moving(tool: .applications, source: source, sourceKey: "savedSettings.\(name)") {+ await TrashService(exclusions: ExclusionsStore.shared.exclusions).trash([copy.folder])+ }if let reason = result.failures.first?.reason {failure = Failure(title: String(localized: "The copy couldn’t be moved to the Trash."), message: reason.explanation)}await history.record(result,tool: .applications,- source: "Settings Saved for \(name)",+ source: source,sourceKey: "savedSettings.\(name)",sizes: [URL: Int64](measured: [(copy.folder, size)]))diff --git a/Peel/Views/Settings/SettingsView.swift b/Peel/Views/Settings/SettingsView.swiftindex fbcab560..f5e1cca2 100644--- a/Peel/Views/Settings/SettingsView.swift+++ b/Peel/Views/Settings/SettingsView.swift@@ -531,12 +531,14 @@ private struct GeneralSettingsView: View {.confirmationDialog("Remove Peel from this Mac?", isPresented: $isConfirmingSelfRemoval) {Button("Remove Peel", role: .destructive) {Task {- await selfUninstall.run(- installedApps: library.apps,- helper: helper,- pausing: background- ) { result in- await history.record(result, tool: .applications, source: "Peel", sizes: [:])+ await history.moving(tool: .applications, source: "Peel") {+ await selfUninstall.run(+ installedApps: library.apps,+ helper: helper,+ pausing: background+ ) { result in+ await history.record(result, tool: .applications, source: "Peel", sizes: [:])+ }}}}diff --git a/Peel/Views/Terminal/TerminalPage.swift b/Peel/Views/Terminal/TerminalPage.swiftindex 24ce5d37..7fc1296e 100644--- a/Peel/Views/Terminal/TerminalPage.swift+++ b/Peel/Views/Terminal/TerminalPage.swift@@ -315,8 +315,12 @@ private struct QuietLoginRow: View {}asked = falseTask {- let result = await terminal.moveQuietLoginToTrash { result, sizes in- await history.record(result, tool: .terminal, source: "Terminal", sourceKey: "tool", sizes: sizes)+ let result = await history.moving(tool: .terminal, source: "Terminal", sourceKey: "tool") {+ await terminal.moveQuietLoginToTrash { result, sizes in+ await history.record(+ result, tool: .terminal, source: "Terminal", sourceKey: "tool", sizes: sizes+ )+ }}asked = niloutcome.report(result)diff --git a/PeelTests/RemovalHistoryStoreTests.swift b/PeelTests/RemovalHistoryStoreTests.swiftindex 49fba3e5..f3005c2c 100644--- a/PeelTests/RemovalHistoryStoreTests.swift+++ b/PeelTests/RemovalHistoryStoreTests.swift@@ -190,9 +190,11 @@ struct RemovalHistoryStoreTests {@Test func tellsAPutBackThatEndsAsTheOneBefore() async throws {let folder = FileManager.default.temporaryDirectory.appending(path: "PeelTests-\(UUID().uuidString)")defer { try? FileManager.default.removeItem(at: folder) }+ let outcome = RemovalOutcome()let history = RemovalHistoryStore(log: RemovalLog(url: folder.appending(path: "removals.json")),refusals: RefusalLog(url: folder.appending(path: "refusals.json")),+ outcome: outcome,knowsTheExclusions: { true },restoring: { items, _ in items.map { _ in .needsHelper } })@@ -203,10 +205,45 @@ struct RemovalHistoryStoreTests {await history.restore(history.records, canUseHelper: false)let first = history.failures+ #expect(outcome.putBackFailures.count == 1)+ outcome.clear()await history.restore(history.records, canUseHelper: false)#expect(history.failures == first)- #expect(history.toldPutBacks == 2, "the second Put Back's alert never showed")+ #expect(outcome.putBackFailures.count == 1, "the second Put Back's alert never showed")+ }++ @Test func aPutBackKeepsItsReasonsWhateverPageIsOnScreenByThen() async throws {+ let folder = FileManager.default.temporaryDirectory.appending(path: "PeelTests-\(UUID().uuidString)")+ defer { try? FileManager.default.removeItem(at: folder) }+ let outcome = RemovalOutcome()+ let history = RemovalHistoryStore(+ log: RemovalLog(url: folder.appending(path: "removals.json")),+ refusals: RefusalLog(url: folder.appending(path: "refusals.json")),+ outcome: outcome,+ knowsTheExclusions: { true },+ restoring: { items, _ in items.map { _ in .needsHelper } }+ )+ var removal = RemovalInProgress()+ let part = RemovalPart(source: "Example", sourceKey: nil, tool: Tool.developer.rawValue)+ await history.record(try moved("Driver"), part: part, sizes: [:], in: &removal)+ history.finish(removal)+ let records = history.records++ await history.restore(records, canUseHelper: false)++ #expect(outcome.putBackFailures.map(\.failure) == [.needsHelper])+ #expect(records.allSatisfy { history.failures[$0.id] == .needsHelper })+ }++ @Test func aMoveTellsTheJournalWhatItIsCalled() async {+ let history = RemovalHistoryStore(knowsTheExclusions: { true })++ let recorded = await history.moving(tool: .plugins, source: "Reverb", sourceKey: "tool") {+ RecordedRemoval.current+ }++ #expect(recorded?.part == RemovalPart(source: "Reverb", sourceKey: "tool", tool: Tool.plugins.rawValue))}@Test func saysWhenStartingOverCouldNotSetTheOldFileAside() async throws {diff --git a/SAFETY.md b/SAFETY.mdindex 29b5233a..ca971d87 100644--- a/SAFETY.md+++ b/SAFETY.md@@ -160,8 +160,8 @@ That includes what `pkgutil` and Homebrew would delete:A removal reaches History even when something cuts it short. Quitting Peel waits until History has it, `peel`carries on through Control-C or a closed terminal until it has written History, and each item Peel moves itself iswritten down the moment it moves, and what its helper moves as soon as the helper answers each request, so one cut-short by a crash or Force Quit still reaches History the next time Peel or `peel` opens it: as an interrupted-removal, or, for a removal of what was selected on several pages, in that removal under its page's name.+short by a crash or Force Quit still reaches History the next time Peel or `peel` opens it, under the name of what+it was removing, or, for a removal `peel` made, as an interrupted removal.Right before anything moves, and again once a second while a removal of many items goes on, Peel looks at the filesother programs of yours hold open, at the program each process runs, and at the script a program such as Node.js or