@@ -148,6 +148,48 @@ extension ProgressManager {
148
148
}
149
149
}
150
150
151
+ internal func getUpdatedURLSummary( property: MetatypeWrapper < URL ? , [ URL ? ] > ) -> [ URL ? ] {
152
+ return state. withLock { state in
153
+
154
+ var value : [ URL ? ] = property. defaultSummary
155
+ property. reduce ( & value, state. propertiesURL [ property] ?? property. defaultValue)
156
+
157
+ guard !state. children. isEmpty else {
158
+ return value
159
+ }
160
+
161
+ for (idx, childState) in state. children. enumerated ( ) {
162
+ if let childPropertyState = childState. childPropertiesURL [ property] {
163
+ if childPropertyState. isDirty {
164
+ // Update dirty path
165
+ if let child = childState. child {
166
+ let updatedSummary = child. getUpdatedURLSummary ( property: property)
167
+ let newChildPropertyState = PropertyStateURL ( value: updatedSummary, isDirty: false )
168
+ state. children [ idx] . childPropertiesURL [ property] = newChildPropertyState
169
+ value = property. merge ( value, updatedSummary)
170
+ }
171
+ } else {
172
+ if let _ = childState. child {
173
+ // Merge non-dirty, updated value
174
+ value = property. merge ( value, childPropertyState. value)
175
+ } else {
176
+ value = property. terminate ( value, childPropertyState. value)
177
+ }
178
+ }
179
+ } else {
180
+ // First fetch of value
181
+ if let child = childState. child {
182
+ let childSummary = child. getUpdatedURLSummary ( property: property)
183
+ let newChildPropertyState = PropertyStateURL ( value: childSummary, isDirty: false )
184
+ state. children [ idx] . childPropertiesURL [ property] = newChildPropertyState
185
+ value = property. merge ( value, childSummary)
186
+ }
187
+ }
188
+ }
189
+ return value
190
+ }
191
+ }
192
+
151
193
internal func getUpdatedFileCount( type: CountType ) -> Int {
152
194
switch type {
153
195
case . total:
@@ -393,6 +435,12 @@ extension ProgressManager {
393
435
}
394
436
}
395
437
438
+ internal func markSelfDirty( property: MetatypeWrapper < URL ? , [ URL ? ] > , parents: [ ParentState ] ) {
439
+ for parentState in parents {
440
+ parentState. parent. markChildDirty ( property: property, at: parentState. positionInParent)
441
+ }
442
+ }
443
+
396
444
internal func markSelfDirty( property: ProgressManager . Properties . TotalFileCount . Type , parents: [ ParentState ] ) {
397
445
for parentState in parents {
398
446
parentState. parent. markChildDirty ( property: property, at: parentState. positionInParent)
@@ -458,6 +506,14 @@ extension ProgressManager {
458
506
}
459
507
markSelfDirty ( property: property, parents: parents)
460
508
}
509
+
510
+ internal func markChildDirty( property: MetatypeWrapper < URL ? , [ URL ? ] > , at position: Int ) {
511
+ let parents = state. withLock { state in
512
+ state. children [ position] . childPropertiesURL [ property] ? . isDirty = true
513
+ return state. parents
514
+ }
515
+ markSelfDirty ( property: property, parents: parents)
516
+ }
461
517
462
518
internal func markChildDirty( property: ProgressManager . Properties . TotalFileCount . Type , at position: Int ) {
463
519
let parents = state. withLock { state in
@@ -516,7 +572,7 @@ extension ProgressManager {
516
572
}
517
573
518
574
//MARK: Method to preserve values of properties upon deinit
519
- 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 ? ] ] ) {
575
+ 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 ? ] ] ) {
520
576
state. withLock { state in
521
577
state. children [ position] . totalFileCount = PropertyStateInt ( value: totalFileCount, isDirty: false )
522
578
state. children [ position] . completedFileCount = PropertyStateInt ( value: completedFileCount, isDirty: false )
@@ -537,6 +593,10 @@ extension ProgressManager {
537
593
for (propertyKey, propertyValue) in propertiesString {
538
594
state. children [ position] . childPropertiesString [ propertyKey] = PropertyStateString ( value: propertyValue, isDirty: false )
539
595
}
596
+
597
+ for (propertyKey, propertyValue) in propertiesURL {
598
+ state. children [ position] . childPropertiesURL [ propertyKey] = PropertyStateURL ( value: propertyValue, isDirty: false )
599
+ }
540
600
}
541
601
}
542
602
}
0 commit comments