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.

Take out of Duplicates' list a copy another page moved, even the one it keeps

Țugui Dragoș80a2e78a84be
diff --git a/Peel/Model/DuplicateLibrary.swift b/Peel/Model/DuplicateLibrary.swift
index 2a342fb3..a8072a0e 100644
--- a/Peel/Model/DuplicateLibrary.swift
+++ b/Peel/Model/DuplicateLibrary.swift
@@ -349,11 +349,13 @@ extension DuplicateLibrary: CarriesSelection {
return result
}
- /// Takes out of the list what another page moved. What this page's own move took is out already.
+ /// Takes out of the list what another page moved, which may be a copy this page shows and never had selected, even
+ /// the one it keeps. What this page's own move took is out already.
func refresh(after parts: [CarriedSelection.Part], apps: AppLibrary) async {
- let selected = selectedURLs.union(selectedFolders)
- let gone = Set(parts.flatMap(\.sizes.keys).filter { selected.contains($0) && $0.isMissing })
- guard let scan, !gone.isEmpty else { return }
+ let asked = selectedURLs.union(selectedFolders).union(parts.flatMap(\.sizes.keys))
+ guard let scan else { return }
+ let gone = scan.copiesGone(inGroupsHolding: asked)
+ guard !gone.isEmpty else { return }
let remaining = scan.removing(gone)
self.scan = remaining
unselect(gone)
diff --git a/Peel/Model/SelectionCarrier.swift b/Peel/Model/SelectionCarrier.swift
index 75fa11ab..e2e3ea47 100644
--- a/Peel/Model/SelectionCarrier.swift
+++ b/Peel/Model/SelectionCarrier.swift
@@ -124,10 +124,11 @@ final class SelectionCarrier {
for part in pass.refused {
tool(of: part)?.deselect(part)
}
- // A tool whose selection holds what another page moved is brought up to date as well.
+ // A tool whose selection holds what another page moved is brought up to date as well, and one that refused
+ // a part, which may be because of what another page moved.
let held = Tool.Group.allCases.flatMap(\.tools).compactMap { tools[$0] }.flatMap(\.carriedParts)
.holding(pass.result.trashed.map(\.originalURL))
- let changed = pass.moved.map(\.part) + held
+ let changed = pass.moved.map(\.part) + held + pass.refused
for name in changed.tools {
guard let tool = Tool(rawValue: name) else { continue }
await tools[tool]?.refresh(after: changed.filter { $0.page.tool == name }, apps: apps)