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.

Duplicates starts no scan while it moves files to the Trash

Țugui Dragoșc27215bdbcdc
diff --git a/Peel/Model/DuplicateLibrary.swift b/Peel/Model/DuplicateLibrary.swift
index 38e27cb1..1a1e4a93 100644
--- a/Peel/Model/DuplicateLibrary.swift
+++ b/Peel/Model/DuplicateLibrary.swift
@@ -90,9 +90,13 @@ final class DuplicateLibrary {
return urls.filter { !finder.canScan($0) }
}
+ /// A scan clears the list, so none starts while a move to the Trash is taking what it lists.
+ var canScan: Bool { !folders.isEmpty && !isRemoving }
+
/// Starts a new scan. The previous one is canceled but not waited for, since a read stuck on a network
/// share would hold back every later scan. Whatever it returns is dropped by its `generation`.
func startScan() {
+ guard canScan else { return }
scanTask?.cancel()
generation += 1
let current = generation
diff --git a/Peel/Views/Duplicates/DuplicateList.swift b/Peel/Views/Duplicates/DuplicateList.swift
index e08387d0..967316bc 100644
--- a/Peel/Views/Duplicates/DuplicateList.swift
+++ b/Peel/Views/Duplicates/DuplicateList.swift
@@ -93,7 +93,7 @@ struct DuplicateList: View {
ToolbarItem {
RescanButton(
isRunning: $isStartingScan,
- isDisabled: duplicates.folders.isEmpty || duplicates.isRemoving,
+ isDisabled: !duplicates.canScan,
title: "Scan",
scan: duplicates
) {
diff --git a/Peel/Views/Duplicates/DuplicateScanForm.swift b/Peel/Views/Duplicates/DuplicateScanForm.swift
index 7636a07c..14492dcb 100644
--- a/Peel/Views/Duplicates/DuplicateScanForm.swift
+++ b/Peel/Views/Duplicates/DuplicateScanForm.swift
@@ -56,7 +56,7 @@ struct DuplicateScanForm: View {
Button("Scan", action: onScan)
.buttonStyle(.borderedProminent)
.keyboardShortcut(.defaultAction)
- .disabled(duplicates.folders.isEmpty || duplicates.isScanning)
+ .disabled(!duplicates.canScan || duplicates.isScanning)
}
.padding([.horizontal, .bottom], 20)
}