Skip to content

Commit 9661753

Browse files
committed
correct calling order of didSet
1 parent c21edd7 commit 9661753

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

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

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -392,18 +392,21 @@ extension ProgressManager {
392392
if P.self == ProgressManager.Properties.TotalFileCount.self {
393393
self.access(keyPath: \.totalFileCount)
394394
self.access(keyPath: \.totalFileCountSummary)
395+
let updatedFileCount = updatedFileCount(type: .total)
395396
self.didSet(keyPath: \.totalFileCountSummary)
396-
return updatedFileCount(type: .total)
397+
return updatedFileCount
397398
} else if P.self == ProgressManager.Properties.CompletedFileCount.self {
398399
self.access(keyPath: \.completedFileCount)
399400
self.access(keyPath: \.completedFileCountSummary)
401+
let updatedFileCount = updatedFileCount(type: .completed)
400402
self.didSet(keyPath: \.completedFileCountSummary)
401-
return updatedFileCount(type: .completed)
403+
return updatedFileCount
402404
} else {
403405
self.access(keyPath: \.customPropertiesInt)
404406
self.access(keyPath: \.customPropertiesIntSummary)
407+
let updatedResult = updatedIntSummary(property: MetatypeWrapper(P.self))
405408
self.didSet(keyPath: \.customPropertiesIntSummary)
406-
return updatedIntSummary(property: MetatypeWrapper(P.self))
409+
return updatedResult
407410
}
408411
}
409412

@@ -419,18 +422,21 @@ extension ProgressManager {
419422
if P.self == ProgressManager.Properties.TotalByteCount.self {
420423
self.access(keyPath: \.totalByteCount)
421424
self.access(keyPath: \.totalByteCountSummary)
425+
let updatedByteCount = updatedByteCount(type: .total)
422426
self.didSet(keyPath: \.totalByteCountSummary)
423-
return updatedByteCount(type: .total)
427+
return updatedByteCount
424428
} else if P.self == ProgressManager.Properties.CompletedByteCount.self {
425429
self.access(keyPath: \.completedByteCount)
426430
self.access(keyPath: \.completedByteCountSummary)
431+
let updatedByteCount = updatedByteCount(type: .completed)
427432
self.didSet(keyPath: \.completedByteCountSummary)
428-
return updatedByteCount(type: .completed)
433+
return updatedByteCount
429434
} else {
430435
self.access(keyPath: \.customPropertiesUInt64)
431436
self.access(keyPath: \.customPropertiesUInt64Summary)
437+
let updatedResult = updatedUInt64Summary(property: MetatypeWrapper(P.self))
432438
self.didSet(keyPath: \.customPropertiesUInt64Summary)
433-
return updatedUInt64Summary(property: MetatypeWrapper(P.self))
439+
return updatedResult
434440
}
435441
}
436442

@@ -445,8 +451,9 @@ extension ProgressManager {
445451
public func summary<P: Property>(of property: KeyPath<ProgressManager.Properties, P.Type>) -> P.Summary where P.Value == Double, P.Summary == Double {
446452
self.access(keyPath: \.customPropertiesDouble)
447453
self.access(keyPath: \.customPropertiesDoubleSummary)
454+
let updatedResult = updatedDoubleSummary(property: MetatypeWrapper(P.self))
448455
self.didSet(keyPath: \.customPropertiesDoubleSummary)
449-
return updatedDoubleSummary(property: MetatypeWrapper(P.self))
456+
return updatedResult
450457
}
451458

452459
/// Returns a summary for a custom string property across the progress subtree.
@@ -460,8 +467,9 @@ extension ProgressManager {
460467
public func summary<P: Property>(of property: KeyPath<ProgressManager.Properties, P.Type>) -> P.Summary where P.Value == String?, P.Summary == [String?] {
461468
self.access(keyPath: \.customPropertiesString)
462469
self.access(keyPath: \.customPropertiesStringSummary)
470+
let updatedResult = updatedStringSummary(property: MetatypeWrapper(P.self))
463471
self.didSet(keyPath: \.customPropertiesStringSummary)
464-
return updatedStringSummary(property: MetatypeWrapper(P.self))
472+
return updatedResult
465473
}
466474

467475
/// Returns a summary for a custom URL property across the progress subtree.
@@ -475,8 +483,9 @@ extension ProgressManager {
475483
public func summary<P: Property>(of property: KeyPath<ProgressManager.Properties, P.Type>) -> P.Summary where P.Value == URL?, P.Summary == [URL?] {
476484
self.access(keyPath: \.customPropertiesURL)
477485
self.access(keyPath: \.customPropertiesURLSummary)
486+
let updatedResult = updatedURLSummary(property: MetatypeWrapper(P.self))
478487
self.didSet(keyPath: \.customPropertiesURLSummary)
479-
return updatedURLSummary(property: MetatypeWrapper(P.self))
488+
return updatedResult
480489
}
481490

482491
/// Returns a summary for a custom unsigned integer property across the progress subtree.
@@ -496,8 +505,9 @@ extension ProgressManager {
496505
} else {
497506
self.access(keyPath: \.customPropertiesUInt64Array)
498507
self.access(keyPath: \.customPropertiesUInt64ArraySummary)
508+
let updatedResult = updatedUInt64ArraySummary(property: MetatypeWrapper(P.self))
499509
self.didSet(keyPath: \.customPropertiesUInt64ArraySummary)
500-
return updatedUInt64ArraySummary(property: MetatypeWrapper(P.self))
510+
return updatedResult
501511
}
502512
}
503513

@@ -513,13 +523,15 @@ extension ProgressManager {
513523
if P.self == ProgressManager.Properties.EstimatedTimeRemaining.self {
514524
self.access(keyPath: \.estimatedTimeRemaining)
515525
self.access(keyPath: \.estimatedTimeRemainingSummary)
526+
let updatedTimeRemaining = updatedEstimatedTimeRemaining()
516527
self.didSet(keyPath: \.estimatedTimeRemainingSummary)
517-
return updatedEstimatedTimeRemaining()
528+
return updatedTimeRemaining
518529
} else {
519530
self.access(keyPath: \.customPropertiesDuration)
520531
self.access(keyPath: \.customPropertiesDurationSummary)
532+
let updatedResult = updatedDurationSummary(property: MetatypeWrapper(P.self))
521533
self.didSet(keyPath: \.customPropertiesDurationSummary)
522-
return updatedDurationSummary(property: MetatypeWrapper(P.self))
534+
return updatedResult
523535
}
524536
}
525537
}

0 commit comments

Comments
 (0)