@@ -139,7 +139,7 @@ extension ProgressManager {
139
139
140
140
/// Returns nil if `self` was instantiated without total units;
141
141
/// returns a `Int` value otherwise.
142
- internal func getTotalCount ( ) -> Int ? {
142
+ internal var totalCount : Int ? {
143
143
#if FOUNDATION_FRAMEWORK
144
144
if let interopTotalCount = interopType? . totalCount {
145
145
return interopTotalCount
@@ -150,7 +150,7 @@ extension ProgressManager {
150
150
151
151
/// Returns 0 if `self` has `nil` total units;
152
152
/// returns a `Int` value otherwise.
153
- internal mutating func getCompletedCount ( ) -> Int {
153
+ internal mutating func completedCount ( ) -> Int {
154
154
#if FOUNDATION_FRAMEWORK
155
155
if let interopCompletedCount = interopType? . completedCount {
156
156
return interopCompletedCount
@@ -160,7 +160,7 @@ extension ProgressManager {
160
160
return selfFraction. completed
161
161
}
162
162
163
- internal mutating func getFractionCompleted ( ) -> Double {
163
+ internal mutating func fractionCompleted ( ) -> Double {
164
164
#if FOUNDATION_FRAMEWORK
165
165
if let interopFractionCompleted = interopType? . fractionCompleted {
166
166
return interopFractionCompleted
@@ -170,7 +170,7 @@ extension ProgressManager {
170
170
return overallFraction. fractionCompleted
171
171
}
172
172
173
- internal func getIsIndeterminate ( ) -> Bool {
173
+ internal var isIndeterminate : Bool {
174
174
#if FOUNDATION_FRAMEWORK
175
175
if let interopIsIndeterminate = interopType? . isIndeterminate {
176
176
return interopIsIndeterminate
@@ -179,7 +179,7 @@ extension ProgressManager {
179
179
return selfFraction. isIndeterminate
180
180
}
181
181
182
- internal mutating func getIsFinished ( ) -> Bool {
182
+ internal mutating func isFinished ( ) -> Bool {
183
183
#if FOUNDATION_FRAMEWORK
184
184
if let interopIsFinished = interopType? . isFinished {
185
185
return interopIsFinished
@@ -227,15 +227,15 @@ extension ProgressManager {
227
227
switch interopType {
228
228
case . interopObservation( let observation) :
229
229
observation. subprogressBridge? . manager. notifyObservers (
230
- with: . fractionUpdated (
230
+ with: ObserverState (
231
231
totalCount: selfFraction. total ?? 0 ,
232
232
completedCount: selfFraction. completed
233
233
)
234
234
)
235
235
236
236
if let _ = observation. reporterBridge {
237
237
notifyObservers (
238
- with: . fractionUpdated (
238
+ with: ObserverState (
239
239
totalCount: selfFraction. total ?? 0 ,
240
240
completedCount: selfFraction. completed
241
241
)
@@ -251,6 +251,9 @@ extension ProgressManager {
251
251
252
252
// MARK: Mark paths dirty
253
253
internal mutating func markChildDirty( at position: Int ) -> [ ParentState ] ? {
254
+ guard position >= 0 && position < children. count else {
255
+ return nil
256
+ }
254
257
guard !children[ position] . isDirty else {
255
258
return nil
256
259
}
@@ -259,66 +262,105 @@ extension ProgressManager {
259
262
}
260
263
261
264
internal mutating func markChildDirty( property: MetatypeWrapper < Int , Int > , at position: Int ) -> [ ParentState ] {
265
+ guard position >= 0 && position < children. count else {
266
+ return parents
267
+ }
262
268
children [ position] . childPropertiesInt [ property] ? . isDirty = true
263
269
return parents
264
270
}
265
271
266
272
internal mutating func markChildDirty( property: MetatypeWrapper < UInt64 , UInt64 > , at position: Int ) -> [ ParentState ] {
273
+ guard position >= 0 && position < children. count else {
274
+ return parents
275
+ }
267
276
children [ position] . childPropertiesUInt64 [ property] ? . isDirty = true
268
277
return parents
269
278
}
270
279
271
280
internal mutating func markChildDirty( property: MetatypeWrapper < Double , Double > , at position: Int ) -> [ ParentState ] {
281
+ guard position >= 0 && position < children. count else {
282
+ return parents
283
+ }
272
284
children [ position] . childPropertiesDouble [ property] ? . isDirty = true
273
285
return parents
274
286
}
275
287
276
288
internal mutating func markChildDirty( property: MetatypeWrapper < String ? , [ String ? ] > , at position: Int ) -> [ ParentState ] {
289
+ guard position >= 0 && position < children. count else {
290
+ return parents
291
+ }
277
292
children [ position] . childPropertiesString [ property] ? . isDirty = true
278
293
return parents
279
294
}
280
295
281
296
internal mutating func markChildDirty( property: MetatypeWrapper < URL ? , [ URL ? ] > , at position: Int ) -> [ ParentState ] {
297
+ guard position >= 0 && position < children. count else {
298
+ return parents
299
+ }
282
300
children [ position] . childPropertiesURL [ property] ? . isDirty = true
283
301
return parents
284
302
}
285
303
286
304
internal mutating func markChildDirty( property: MetatypeWrapper < UInt64 , [ UInt64 ] > , at position: Int ) -> [ ParentState ] {
305
+ guard position >= 0 && position < children. count else {
306
+ return parents
307
+ }
287
308
children [ position] . childPropertiesUInt64Array [ property] ? . isDirty = true
288
309
return parents
289
310
}
290
311
291
312
internal mutating func markChildDirty( property: MetatypeWrapper < Duration , Duration > , at position: Int ) -> [ ParentState ] {
313
+ guard position >= 0 && position < children. count else {
314
+ return parents
315
+ }
292
316
children [ position] . childPropertiesDuration [ property] ? . isDirty = true
293
317
return parents
294
318
}
295
319
296
320
internal mutating func markChildDirty( property: ProgressManager . Properties . TotalFileCount . Type , at position: Int ) -> [ ParentState ] {
321
+ guard position >= 0 && position < children. count else {
322
+ return parents
323
+ }
297
324
children [ position] . totalFileCount. isDirty = true
298
325
return parents
299
326
}
300
327
301
328
internal mutating func markChildDirty( property: ProgressManager . Properties . CompletedFileCount . Type , at position: Int ) -> [ ParentState ] {
329
+ guard position >= 0 && position < children. count else {
330
+ return parents
331
+ }
302
332
children [ position] . completedFileCount. isDirty = true
303
333
return parents
304
334
}
305
335
306
336
internal mutating func markChildDirty( property: ProgressManager . Properties . TotalByteCount . Type , at position: Int ) -> [ ParentState ] {
337
+ guard position >= 0 && position < children. count else {
338
+ return parents
339
+ }
307
340
children [ position] . totalByteCount. isDirty = true
308
341
return parents
309
342
}
310
343
311
344
internal mutating func markChildDirty( property: ProgressManager . Properties . CompletedByteCount . Type , at position: Int ) -> [ ParentState ] {
345
+ guard position >= 0 && position < children. count else {
346
+ return parents
347
+ }
312
348
children [ position] . completedByteCount. isDirty = true
313
349
return parents
314
350
}
315
351
316
352
internal mutating func markChildDirty( property: ProgressManager . Properties . Throughput . Type , at position: Int ) -> [ ParentState ] {
353
+ guard position >= 0 && position < children. count else {
354
+ return parents
355
+ }
317
356
children [ position] . throughput. isDirty = true
318
357
return parents
319
358
}
320
359
321
360
internal mutating func markChildDirty( property: ProgressManager . Properties . EstimatedTimeRemaining . Type , at position: Int ) -> [ ParentState ] {
361
+ guard position >= 0 && position < children. count else {
362
+ return parents
363
+ }
322
364
children [ position] . estimatedTimeRemaining. isDirty = true
323
365
return parents
324
366
}
0 commit comments