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
Keep an area's page open in Space after a move leaves it small
Țugui Dragoș4dea2390123b
diff --git a/Packages/PeelCore/Sources/PeelCore/Space/SpaceReport.swift b/Packages/PeelCore/Sources/PeelCore/Space/SpaceReport.swiftindex e20e7784..2b092be0 100644--- a/Packages/PeelCore/Sources/PeelCore/Space/SpaceReport.swift+++ b/Packages/PeelCore/Sources/PeelCore/Space/SpaceReport.swift@@ -504,6 +504,7 @@ public enum SpaceInventory {public static func scan(in environment: SearchEnvironment = .current,minimumSize: Int64 = SpaceInventory.minimumSize,+ keeping: Set<String> = [],exclusions: Exclusions = .none) async -> SpaceReport {await scan(@@ -511,6 +512,7 @@ public enum SpaceInventory {root: environment.rootDirectory,userCache: environment.userCacheDirectory,minimumSize: minimumSize,+ keeping: keeping,exclusions: exclusions,measure: LeftoverScanner.walk)@@ -523,6 +525,7 @@ public enum SpaceInventory {root: URL = URL(filePath: "/", directoryHint: .isDirectory),userCache: URL? = nil,minimumSize: Int64,+ keeping: Set<String> = [],exclusions: Exclusions = .none,measure: @escaping LeftoverScanner.Measure,simctlRuntimeHelp: @escaping @Sendable () async -> String? = { await Simctl.runtimeHelp() }@@ -565,7 +568,10 @@ public enum SpaceInventory {}}let help = await simctlHelp- let shown = measured.filter { !$0.size.isComplete || $0.size.known >= minimumSize }+ // An area in `keeping`, open on its page, stays listed whatever its size, so a move doesn't close its page.+ let shown = measured.filter {+ keeping.contains($0.definition.id) || !$0.size.isComplete || $0.size.known >= minimumSize+ }let items = shown.map { definition, urls, size initem(definition, urls: urls, size: size, home: home, root: root, simctlRuntimeHelp: help)}diff --git a/Packages/PeelCore/Tests/PeelCoreTests/SpaceInventoryTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/SpaceInventoryTests.swiftindex d0d1ecaf..04bb1b1f 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/SpaceInventoryTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/SpaceInventoryTests.swift@@ -63,6 +63,11 @@ struct SpaceInventoryTests {home: directory.url, root: root, minimumSize: 1, measure: LeftoverScanner.walk)#expect(Set(everything.items.map(\.id)) == ["logs", "colima"])++ let keepingColima = await SpaceInventory.scan(+ home: directory.url, root: root, minimumSize: 100_000, keeping: ["colima"], measure: LeftoverScanner.walk+ )+ #expect(Set(keepingColima.items.map(\.id)) == ["logs", "colima"], "an area open on its page left the list")}/// The folders Space exists to show are the ones most likely to run out of time. Such a folder stays in thediff --git a/Peel/Model/SpaceLibrary.swift b/Peel/Model/SpaceLibrary.swiftindex ae5e688e..641a436a 100644--- a/Peel/Model/SpaceLibrary.swift+++ b/Peel/Model/SpaceLibrary.swift@@ -30,7 +30,7 @@ final class SpaceLibrary: RowSelection {}func refresh() async {- await refresh(replanning: [])+ await refresh(replanning: [], keepingTheOpenArea: true)}func readDisk() async {@@ -40,7 +40,7 @@ final class SpaceLibrary: RowSelection {/// Scans again and makes every area's plan again, as Rescan asks: a plan also depends on which apps are open,/// which the area's size does not show.func rescan() async {- await refresh(replanning: Set(plans.keys))+ await refresh(replanning: Set(plans.keys), keepingTheOpenArea: false)}/// Makes the area's plan from what is on disk now, keeping what was chosen in it.@@ -133,11 +133,13 @@ final class SpaceLibrary: RowSelection {/// Scans again, and makes again the plans of the areas in `replanning` and of every area that changed since/// its plan was made, so what is carried from them follows what is on disk. The plans are part of the scan, so- /// an area's page stays busy until it shows what is there now.- private func refresh(replanning: Set<SpaceItem.ID>) async {+ /// an area's page stays busy until it shows what is there now. The area open on its page stays listed, however+ /// small a move left it, until the person asks for a Rescan.+ private func refresh(replanning: Set<SpaceItem.ID>, keepingTheOpenArea: Bool) async {let exclusions = ExclusionsStore.shared.exclusions+ let keeping = keepingTheOpenArea ? Set([selection].compactMap(\.self)) : []let answer = await scanRun.run {- let result = await SpaceInventory.scan(exclusions: exclusions)+ let result = await SpaceInventory.scan(keeping: keeping, exclusions: exclusions)var made: [(item: SpaceItem, plan: SpaceRemoval.Plan, exclusions: Int)] = []for item in result.items where self.plans[item.id] != nil && !Task.isCancelled {let planned = self.plannedFor[item.id]@@ -222,7 +224,7 @@ extension SpaceLibrary: CarriesSelection {}func refresh(after parts: [CarriedSelection.Part], apps: AppLibrary) async {- await refresh(replanning: Set(parts.map(\.page.scope)))+ await refresh(replanning: Set(parts.map(\.page.scope)), keepingTheOpenArea: true)}func choose(_ page: CarriedSelection.Page) {