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
Ask the helper again at the quality of its wait, whatever the task that asks
Țugui Dragoș5f1e587f450e
diff --git a/Packages/PeelCore/Sources/PeelCore/Removal/PrivilegedHelper.swift b/Packages/PeelCore/Sources/PeelCore/Removal/PrivilegedHelper.swiftindex 2ed1a797..0aeceb6a 100644--- a/Packages/PeelCore/Sources/PeelCore/Removal/PrivilegedHelper.swift+++ b/Packages/PeelCore/Sources/PeelCore/Removal/PrivilegedHelper.swift@@ -169,21 +169,25 @@ public enum PrivilegedHelper {},untilEnded: @escaping @Sendable (pid_t, TimeInterval) async -> Bool = { await ProcessEnds.ends($0, within: $1) }) async -> Bool {- let deadline = ContinuousClock.now.advanced(by: .seconds(wait))- let left = { ContinuousClock.now.duration(to: deadline) / .seconds(1) }- let asked = Date.now- let first = await askVersion(connecting: connect, waitingAtMost: wait)- if first.value == HelperIdentity.protocolVersion { return true }- guard first.value != nil || first.wasRejected else { return false }- // A helper of another version, or one XPC turns away because an update deleted its program, is one the update- // left running: it leaves as soon as no connection is open (`HelperLifetime`), and launchd then starts the one- // this copy carries. Another copy's helper keeps running.- var process = first.process- if process == nil { process = await runningHelper(asked, left()) }- if let process {- guard await untilEnded(process, left()) else { return false }- }- return await askVersion(connecting: connect, waitingAtMost: left()).value == HelperIdentity.protocolVersion+ // The steps between two questions run at the timers' quality too: a task that asks at a lower one resumes+ // behind Peel's busy threads, and the wait it spent there would be taken from a helper that answered.+ await Task.detached(priority: .userInitiated) {+ let deadline = ContinuousClock.now.advanced(by: .seconds(wait))+ let left = { ContinuousClock.now.duration(to: deadline) / .seconds(1) }+ let asked = Date.now+ let first = await askVersion(connecting: connect, waitingAtMost: wait)+ if first.value == HelperIdentity.protocolVersion { return true }+ guard first.value != nil || first.wasRejected else { return false }+ // A helper of another version, or one XPC turns away because an update deleted its program, is one the+ // update left running: it leaves as soon as no connection is open (`HelperLifetime`), and launchd then+ // starts the one this copy carries. Another copy's helper keeps running.+ var process = first.process+ if process == nil { process = await runningHelper(asked, left()) }+ if let process {+ guard await untilEnded(process, left()) else { return false }+ }+ return await askVersion(connecting: connect, waitingAtMost: left()).value == HelperIdentity.protocolVersion+ }.value}/// The process launchd runs the helper in, if it already ran when Peel asked at `date`: XPC names no process whosediff --git a/Packages/PeelCore/Tests/PeelCoreTests/HelperAnswerTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/HelperAnswerTests.swiftindex 74e10d19..df775dc4 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/HelperAnswerTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/HelperAnswerTests.swift@@ -271,4 +271,30 @@ struct HelperAnswerTests {#expect((helper.handledAt.withLock { $0 } ?? 0) >= QOS_CLASS_USER_INITIATED.rawValue)#expect((sentAt.value.withLock { $0 } ?? 0) >= QOS_CLASS_USER_INITIATED.rawValue)}++ @Test func aHelperTurnedAwayIsWaitedForAtTheQualityOfItsWaitWhateverTheTaskThatAsks() async {+ let helper = StandInHelper(answering: HelperIdentity.protocolVersion, rejectingFirst: 1)+ defer { helper.stop() }+ let connecting = helper.connecting+ let lookedUpAt = Record<UInt32?>(nil)+ let watchedAt = Record<UInt32?>(nil)++ let answering = await Task.detached(priority: .background) {+ await PrivilegedHelper.isResponding(+ connecting: connecting, waitingAtMost: Self.anyWait,+ runningHelper: { _, _ in+ lookedUpAt.value.withLock { $0 = qos_class_self().rawValue }+ return getpid()+ },+ untilEnded: { _, _ in+ watchedAt.value.withLock { $0 = qos_class_self().rawValue }+ return true+ }+ )+ }.value++ #expect(answering)+ #expect((lookedUpAt.value.withLock { $0 } ?? 0) >= QOS_CLASS_USER_INITIATED.rawValue)+ #expect((watchedAt.value.withLock { $0 } ?? 0) >= QOS_CLASS_USER_INITIATED.rawValue)+ }}