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
Space measures a few folders at a time when it plans an area
Țugui Dragoș0d55c9fff6d1
diff --git a/Packages/PeelCore/Sources/PeelCore/Space/SpaceRemoval.swift b/Packages/PeelCore/Sources/PeelCore/Space/SpaceRemoval.swiftindex ebf9cf8b..9c5635ce 100644--- a/Packages/PeelCore/Sources/PeelCore/Space/SpaceRemoval.swift+++ b/Packages/PeelCore/Sources/PeelCore/Space/SpaceRemoval.swift@@ -54,7 +54,7 @@ public enum SpaceRemoval {environment: SearchEnvironment,exclusions: Exclusions = .none,running: [String: String] = [:],- measure: LeftoverScanner.Measure = LeftoverScanner.walk+ measure: @escaping LeftoverScanner.Measure = LeftoverScanner.walk) async -> Plan {let children = children(of: item, environment: environment, exclusions: exclusions, running: running)let systemCaches = SystemCaches(environment: environment)@@ -62,8 +62,10 @@ public enum SpaceRemoval {var sizes: [URL: Int64] = [:]var heldBack: [URL: HoldBack] = [:]var needsTheHelper: Set<URL> = []- for child in children.removable where !Task.isCancelled {- let contents = await measure(child)+ let measured = await children.removable.concurrentMap(width: LeftoverScanner.concurrentMeasurements) { child in+ (child, await measure(child))+ }+ for (child, contents) in measured {sizes[child] = contents.flatMap { $0.couldNotBeRead ? nil : $0.size }let needsAnAdministrator = FileAccess.requiresPrivilegesToRemove(child)if needsAnAdministrator { needsTheHelper.insert(child) }diff --git a/Packages/PeelCore/Tests/PeelCoreTests/SpaceRemovalTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/SpaceRemovalTests.swiftindex 03c6952d..0b25ad1b 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/SpaceRemovalTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/SpaceRemovalTests.swift@@ -1,5 +1,6 @@import Foundation@testable import PeelCore+import Synchronizationimport Testing/// Space empties a folder by listing what is inside it. Each item listed still goes through the guard and the@@ -462,6 +463,24 @@ struct SpaceRemovalTests {#expect(plan.heldBack.map { "\($0.key.lastPathComponent): \($0.value.rawValue)" } == ["com.slow.app: notMeasured"])}+ @Test func measuresAFewChildrenAtATime() async throws {+ let directory = try TemporaryDirectory()+ for index in 0..<8 {+ try directory.file("home/Library/Caches/org.example.app\(index)/blob", bytes: 4_000)+ }+ let running = Mutex((now: 0, most: 0))++ let plan = await SpaceRemoval.plan(for: item(directory), environment: environment(directory), exclusions: .none, running: [:]) { _ in+ running.withLock { $0.now += 1; $0.most = max($0.most, $0.now) }+ try? await Task.sleep(for: .milliseconds(500))+ running.withLock { $0.now -= 1 }+ return FolderContents(size: 4_000, holdsRepository: false)+ }++ #expect(plan.sizes.count == 8)+ #expect(running.withLock { $0.most } == LeftoverScanner.concurrentMeasurements)+ }+/// An area's plan is made again when the disk changes, and what the person chose in it stays chosen: a child/// that was already there keeps its checkbox as it was, one new to the area is selected when its size is/// known, as every child is in the area's first plan, and one that went is no longer selected. A child Peel