@@ -191,6 +191,48 @@ extension ProgressManager {
191
191
}
192
192
}
193
193
194
+ internal func getUpdatedUInt64Summary( property: MetatypeWrapper < UInt64 , [ UInt64 ] > ) -> [ UInt64 ] {
195
+ return state. withLock { state in
196
+
197
+ var value : [ UInt64 ] = property. defaultSummary
198
+ property. reduce ( & value, state. propertiesUInt64 [ property] ?? property. defaultValue)
199
+
200
+ guard !state. children. isEmpty else {
201
+ return value
202
+ }
203
+
204
+ for (idx, childState) in state. children. enumerated ( ) {
205
+ if let childPropertyState = childState. childPropertiesUInt64 [ property] {
206
+ if childPropertyState. isDirty {
207
+ // Update dirty path
208
+ if let child = childState. child {
209
+ let updatedSummary = child. getUpdatedUInt64Summary ( property: property)
210
+ let newChildPropertyState = PropertyStateThroughput ( value: updatedSummary, isDirty: false )
211
+ state. children [ idx] . childPropertiesUInt64 [ property] = newChildPropertyState
212
+ value = property. merge ( value, updatedSummary)
213
+ }
214
+ } else {
215
+ if let _ = childState. child {
216
+ // Merge non-dirty, updated value
217
+ value = property. merge ( value, childPropertyState. value)
218
+ } else {
219
+ value = property. terminate ( value, childPropertyState. value)
220
+ }
221
+ }
222
+ } else {
223
+ // First fetch of value
224
+ if let child = childState. child {
225
+ let childSummary = child. getUpdatedUInt64Summary ( property: property)
226
+ let newChildPropertyState = PropertyStateThroughput ( value: childSummary, isDirty: false )
227
+ state. children [ idx] . childPropertiesUInt64 [ property] = newChildPropertyState
228
+ value = property. merge ( value, childSummary)
229
+ }
230
+ }
231
+ }
232
+ return value
233
+ }
234
+ }
235
+
194
236
internal func getUpdatedFileCount( type: CountType ) -> Int {
195
237
switch type {
196
238
case . total:
@@ -443,6 +485,12 @@ extension ProgressManager {
443
485
}
444
486
}
445
487
488
+ internal func markSelfDirty( property: MetatypeWrapper < UInt64 , [ UInt64 ] > , parents: [ ParentState ] ) {
489
+ for parentState in parents {
490
+ parentState. parent. markChildDirty ( property: property, at: parentState. positionInParent)
491
+ }
492
+ }
493
+
446
494
internal func markSelfDirty( property: ProgressManager . Properties . TotalFileCount . Type , parents: [ ParentState ] ) {
447
495
for parentState in parents {
448
496
parentState. parent. markChildDirty ( property: property, at: parentState. positionInParent)
@@ -516,6 +564,14 @@ extension ProgressManager {
516
564
}
517
565
markSelfDirty ( property: property, parents: parents)
518
566
}
567
+
568
+ internal func markChildDirty( property: MetatypeWrapper < UInt64 , [ UInt64 ] > , at position: Int ) {
569
+ let parents = state. withLock { state in
570
+ state. children [ position] . childPropertiesUInt64 [ property] ? . isDirty = true
571
+ return state. parents
572
+ }
573
+ markSelfDirty ( property: property, parents: parents)
574
+ }
519
575
520
576
internal func markChildDirty( property: ProgressManager . Properties . TotalFileCount . Type , at position: Int ) {
521
577
let parents = state. withLock { state in
@@ -574,7 +630,7 @@ extension ProgressManager {
574
630
}
575
631
576
632
//MARK: Method to preserve values of properties upon deinit
577
- internal func setChildDeclaredAdditionalProperties( at position: Int , totalFileCount: Int , completedFileCount: Int , totalByteCount: UInt64 , completedByteCount: UInt64 , throughput: [ UInt64 ] , estimatedTimeRemaining: Duration , fileURL: [ URL ? ] , propertiesInt: [ MetatypeWrapper < Int , Int > : Int ] , propertiesDouble: [ MetatypeWrapper < Double , Double > : Double ] , propertiesString: [ MetatypeWrapper < String ? , [ String ? ] > : [ String ? ] ] , propertiesURL: [ MetatypeWrapper < URL ? , [ URL ? ] > : [ URL ? ] ] ) {
633
+ internal func setChildDeclaredAdditionalProperties( at position: Int , totalFileCount: Int , completedFileCount: Int , totalByteCount: UInt64 , completedByteCount: UInt64 , throughput: [ UInt64 ] , estimatedTimeRemaining: Duration , fileURL: [ URL ? ] , propertiesInt: [ MetatypeWrapper < Int , Int > : Int ] , propertiesDouble: [ MetatypeWrapper < Double , Double > : Double ] , propertiesString: [ MetatypeWrapper < String ? , [ String ? ] > : [ String ? ] ] , propertiesURL: [ MetatypeWrapper < URL ? , [ URL ? ] > : [ URL ? ] ] , propertiesUInt64 : [ MetatypeWrapper < UInt64 , [ UInt64 ] > : [ UInt64 ] ] ) {
578
634
state. withLock { state in
579
635
state. children [ position] . totalFileCount = PropertyStateInt ( value: totalFileCount, isDirty: false )
580
636
state. children [ position] . completedFileCount = PropertyStateInt ( value: completedFileCount, isDirty: false )
@@ -599,6 +655,10 @@ extension ProgressManager {
599
655
for (propertyKey, propertyValue) in propertiesURL {
600
656
state. children [ position] . childPropertiesURL [ propertyKey] = PropertyStateURL ( value: propertyValue, isDirty: false )
601
657
}
658
+
659
+ for (propertyKey, propertyValue) in propertiesUInt64 {
660
+ state. children [ position] . childPropertiesUInt64 [ propertyKey] = PropertyStateThroughput ( value: propertyValue, isDirty: false )
661
+ }
602
662
}
603
663
}
604
664
}
0 commit comments