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
Background Items writes a move into History before it scans again
Țugui Dragoșae0f2f10cc63
diff --git a/Peel/Model/BackgroundItemLibrary.swift b/Peel/Model/BackgroundItemLibrary.swiftindex 11659da6..e7fedc57 100644--- a/Peel/Model/BackgroundItemLibrary.swift+++ b/Peel/Model/BackgroundItemLibrary.swift@@ -44,11 +44,13 @@ final class BackgroundItemLibrary {let reason: BackgroundItemActions.Failure}- @discardableResult- func perform(_ action: Action, on item: BackgroundItem) async -> TrashResult {+ /// Runs `action` on `item`, then scans again. What a move to the Trash moved and refused goes to `record` before+ /// the rescan, which can take a while: History is the way back for what just moved.+ func perform(+ _ action: Action, on item: BackgroundItem, recording record: (TrashResult) async -> Void = { _ in }+ ) async {runningActionItemIDs.insert(item.id)defer { runningActionItemIDs.remove(item.id) }- var result = TrashResult()do {switch action {case .start: try await BackgroundItemActions.start(item)@@ -56,7 +58,9 @@ final class BackgroundItemLibrary {case .enable: try await BackgroundItemActions.setEnabled(true, for: item)case .disable: try await BackgroundItemActions.setEnabled(false, for: item)case .moveToTrash:- result = try await BackgroundItemActions.moveToTrash(item, exclusions: ExclusionsStore.shared.exclusions)+ let exclusions = ExclusionsStore.shared.exclusions+ let result = try await BackgroundItemActions.moveToTrash(item, exclusions: exclusions)+ await record(result)if let refusal = result.failures.first {failure = ActionFailure(action: action, reason: .trash(refusal.reason))}@@ -65,6 +69,5 @@ final class BackgroundItemLibrary {failure = ActionFailure(action: action, reason: error)}await refresh(installedApps: installedApps)- return result}}diff --git a/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift b/Peel/Views/BackgroundItems/BackgroundItemDetailView.swiftindex b74880b4..6cda4282 100644--- a/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift+++ b/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift@@ -147,8 +147,9 @@ struct BackgroundItemDetailView: View {if let plist = item.plistURL {sizes[plist] = await FileSize.allocatedSize(of: plist)}- let result = await backgroundItems.perform(.moveToTrash, on: item)- await history.record(result, tool: .backgroundItems, source: item.label, sizes: sizes)+ await backgroundItems.perform(.moveToTrash, on: item) { result in+ await history.record(result, tool: .backgroundItems, source: item.label, sizes: sizes)+ }}}Button("Cancel", role: .cancel) {}