Skip to content

Commit 678037e

Browse files
committed
working additional properties version
1 parent 9b4cc64 commit 678037e

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

Sources/FoundationEssentials/ProgressManager/ProgressManager+Properties+Accessors.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ extension ProgressManager {
413413

414414
// MARK: Methods to Read Additional Properties of Subtree with ProgressManager as root
415415

416+
416417
/// Returns a summary for a custom integer property across the progress subtree.
417418
///
418419
/// This method aggregates the values of a custom integer property from this progress manager
@@ -423,7 +424,9 @@ extension ProgressManager {
423424
/// - Returns: An `Int` summary value for the specified property.
424425
public func summary<P: Property>(of property: P.Type) -> P.Summary where P.Value == Int, P.Summary == Int {
425426
if property.self == ProgressManager.Properties.TotalFileCount.self {
427+
self.access(keyPath: \.summarySink)
426428
self.access(keyPath: \.totalFileCount)
429+
self.didSet(keyPath: \.summarySink)
427430
return updatedFileCount(type: .total)
428431
} else if property.self == ProgressManager.Properties.CompletedFileCount.self {
429432
self.access(keyPath: \.completedFileCount)

Sources/FoundationEssentials/ProgressManager/ProgressManager+Properties+Helpers.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ extension ProgressManager {
145145
state.getFileCountUpdateInfo(type: type)
146146
}
147147

148+
// for child in updateInfo.dirtyChildren.compactMap({ $0.manager }) {
149+
// child.access(keyPath: \.summarySink)
150+
// }
151+
148152
// Get updated summary for each dirty child
149153
let updatedSummaries = updateInfo.dirtyChildren.map { (index, child) in
150154
State.FileCountUpdate(index: index, updatedSummary: child.updatedFileCount(type: type))
@@ -337,10 +341,11 @@ extension ProgressManager {
337341
}
338342

339343
internal func markChildDirty(property: ProgressManager.Properties.TotalFileCount.Type, at position: Int) {
340-
let parents = state.withLock { state in
341-
state.markChildDirty(property: property, at: position)
342-
}
343-
markSelfDirty(property: property, parents: parents)
344+
self.willSet(keyPath: \.summarySink)
345+
let parents = state.withLock { state in
346+
state.markChildDirty(property: property, at: position)
347+
}
348+
markSelfDirty(property: property, parents: parents)
344349
}
345350

346351
internal func markChildDirty(property: ProgressManager.Properties.CompletedFileCount.Type, at position: Int) {

Sources/FoundationEssentials/ProgressManager/ProgressManager.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ internal import _FoundationCollections
2828

2929
internal let state: Mutex<State>
3030
internal let additionalPropertiesSink: Void
31+
internal let summarySink: Void
3132

3233
/// The total units of work.
3334
public var totalCount: Int? {

0 commit comments

Comments
 (0)