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
Developer and Build Artifacts keep choices by the same rule
Țugui Dragoșe5fdb0c90d23
diff --git a/Peel/Model/DeveloperLibrary.swift b/Peel/Model/DeveloperLibrary.swiftindex d4f87953..aa689db7 100644--- a/Peel/Model/DeveloperLibrary.swift+++ b/Peel/Model/DeveloperLibrary.swift@@ -12,6 +12,7 @@ final class DeveloperLibrary {private(set) var isRemoving = falsevar selection: DeveloperEnvironment.ID?var selectedURLs: Set<URL> = []+ private var choices = KeptSelection()var selectedEnvironment: DeveloperEnvironment? {environments?.first { $0.id == selection }@@ -19,12 +20,13 @@ final class DeveloperLibrary {func refresh() async {guard let result = await scanRun.run({ await DeveloperCaches.scan(exclusions: ExclusionsStore.shared.exclusions) }) else { return }- // Selects only recommended locations new to this scan, so what the user deselected stays deselected.- let previous = Set(environments?.flatMap(\.locations).map(\.url) ?? [])environments = resultlet locations = result.flatMap(\.locations)- selectedURLs.formIntersection(Set(locations.map(\.url)))- selectedURLs.formUnion(locations.filter { $0.isRecommended && !previous.contains($0.url) }.map(\.url))+ selectedURLs = choices.update(+ selectedURLs,+ selectable: Set(locations.map(\.url)),+ suggested: Set(locations.filter(\.isRecommended).map(\.url))+ )if let selection, !result.contains(where: { $0.id == selection }) {self.selection = nil}diff --git a/Peel/Model/ProjectLibrary.swift b/Peel/Model/ProjectLibrary.swiftindex c8cd81d2..40f66327 100644--- a/Peel/Model/ProjectLibrary.swift+++ b/Peel/Model/ProjectLibrary.swift@@ -38,6 +38,7 @@ final class ProjectLibrary {private(set) var refused: [(url: URL, reason: ProjectArtifacts.Refusal)] = []var selection: URL?var selectedURLs: Set<URL> = []+ private var choices = KeptSelection()init() {folders = (UserDefaults.standard.array(forKey: Self.foldersKey) as? [String] ?? [])@@ -51,8 +52,6 @@ final class ProjectLibrary {/// Scans the chosen folders. It scans even when none is chosen: that scan ends at once and overtakes any/// older scan of a folder just removed from the list, whose results then never land.func refresh() async {- let previous = Set(groups?.flatMap(\.artifacts).map(\.url) ?? [])- let suggestedAndSelected = Set(groups?.flatMap(\.artifacts).filter { $0.isRecommended && selectedURLs.contains($0.url) }.map(\.url) ?? [])let folders = foldersguard let (scan, standings) = await scanRun.run({let scan = await ProjectArtifacts.scan(roots: folders, exclusions: ExclusionsStore.shared.exclusions)@@ -67,13 +66,11 @@ final class ProjectLibrary {groups = resultexcludedFromBackups = Set(standings.filter { $0.value != .included }.keys)excludedFromAbove = Set(standings.filter { $0.value == .excludedFromAbove }.keys)- selectedURLs.formIntersection(Set(artifacts.map(\.url)))- // Selects the recommended artifacts this scan found for the first time, so what the user deselected- // stays deselected.- selectedURLs.formUnion(artifacts.filter { $0.isRecommended && !previous.contains($0.url) }.map(\.url))- // Deselects what Peel had selected when it stops being recommended, for example because the project- // is being worked on again, as its row says.- selectedURLs.subtract(artifacts.filter { !$0.isRecommended && suggestedAndSelected.contains($0.url) }.map(\.url))+ selectedURLs = choices.update(+ selectedURLs,+ selectable: Set(artifacts.map(\.url)),+ suggested: Set(artifacts.filter(\.isRecommended).map(\.url))+ )if let selection, !result.contains(where: { $0.project == selection }) {self.selection = nil}