@@ -139,7 +139,7 @@ extension ProgressManager {
139139
140140 /// Returns nil if `self` was instantiated without total units;
141141 /// returns a `Int` value otherwise.
142- internal func getTotalCount ( ) -> Int ? {
142+ internal var totalCount : Int ? {
143143#if FOUNDATION_FRAMEWORK
144144 if let interopTotalCount = interopType? . totalCount {
145145 return interopTotalCount
@@ -150,7 +150,7 @@ extension ProgressManager {
150150
151151 /// Returns 0 if `self` has `nil` total units;
152152 /// returns a `Int` value otherwise.
153- internal mutating func getCompletedCount ( ) -> Int {
153+ internal mutating func completedCount ( ) -> Int {
154154#if FOUNDATION_FRAMEWORK
155155 if let interopCompletedCount = interopType? . completedCount {
156156 return interopCompletedCount
@@ -160,7 +160,7 @@ extension ProgressManager {
160160 return selfFraction. completed
161161 }
162162
163- internal mutating func getFractionCompleted ( ) -> Double {
163+ internal mutating func fractionCompleted ( ) -> Double {
164164#if FOUNDATION_FRAMEWORK
165165 if let interopFractionCompleted = interopType? . fractionCompleted {
166166 return interopFractionCompleted
@@ -170,7 +170,7 @@ extension ProgressManager {
170170 return overallFraction. fractionCompleted
171171 }
172172
173- internal func getIsIndeterminate ( ) -> Bool {
173+ internal var isIndeterminate : Bool {
174174#if FOUNDATION_FRAMEWORK
175175 if let interopIsIndeterminate = interopType? . isIndeterminate {
176176 return interopIsIndeterminate
@@ -179,7 +179,7 @@ extension ProgressManager {
179179 return selfFraction. isIndeterminate
180180 }
181181
182- internal mutating func getIsFinished ( ) -> Bool {
182+ internal mutating func isFinished ( ) -> Bool {
183183#if FOUNDATION_FRAMEWORK
184184 if let interopIsFinished = interopType? . isFinished {
185185 return interopIsFinished
@@ -227,15 +227,15 @@ extension ProgressManager {
227227 switch interopType {
228228 case . interopObservation( let observation) :
229229 observation. subprogressBridge? . manager. notifyObservers (
230- with: . fractionUpdated (
230+ with: ObserverState (
231231 totalCount: selfFraction. total ?? 0 ,
232232 completedCount: selfFraction. completed
233233 )
234234 )
235235
236236 if let _ = observation. reporterBridge {
237237 notifyObservers (
238- with: . fractionUpdated (
238+ with: ObserverState (
239239 totalCount: selfFraction. total ?? 0 ,
240240 completedCount: selfFraction. completed
241241 )
@@ -251,6 +251,9 @@ extension ProgressManager {
251251
252252 // MARK: Mark paths dirty
253253 internal mutating func markChildDirty( at position: Int ) -> [ ParentState ] ? {
254+ guard position >= 0 && position < children. count else {
255+ return nil
256+ }
254257 guard !children[ position] . isDirty else {
255258 return nil
256259 }
@@ -259,66 +262,105 @@ extension ProgressManager {
259262 }
260263
261264 internal mutating func markChildDirty( property: MetatypeWrapper < Int , Int > , at position: Int ) -> [ ParentState ] {
265+ guard position >= 0 && position < children. count else {
266+ return parents
267+ }
262268 children [ position] . childPropertiesInt [ property] ? . isDirty = true
263269 return parents
264270 }
265271
266272 internal mutating func markChildDirty( property: MetatypeWrapper < UInt64 , UInt64 > , at position: Int ) -> [ ParentState ] {
273+ guard position >= 0 && position < children. count else {
274+ return parents
275+ }
267276 children [ position] . childPropertiesUInt64 [ property] ? . isDirty = true
268277 return parents
269278 }
270279
271280 internal mutating func markChildDirty( property: MetatypeWrapper < Double , Double > , at position: Int ) -> [ ParentState ] {
281+ guard position >= 0 && position < children. count else {
282+ return parents
283+ }
272284 children [ position] . childPropertiesDouble [ property] ? . isDirty = true
273285 return parents
274286 }
275287
276288 internal mutating func markChildDirty( property: MetatypeWrapper < String ? , [ String ? ] > , at position: Int ) -> [ ParentState ] {
289+ guard position >= 0 && position < children. count else {
290+ return parents
291+ }
277292 children [ position] . childPropertiesString [ property] ? . isDirty = true
278293 return parents
279294 }
280295
281296 internal mutating func markChildDirty( property: MetatypeWrapper < URL ? , [ URL ? ] > , at position: Int ) -> [ ParentState ] {
297+ guard position >= 0 && position < children. count else {
298+ return parents
299+ }
282300 children [ position] . childPropertiesURL [ property] ? . isDirty = true
283301 return parents
284302 }
285303
286304 internal mutating func markChildDirty( property: MetatypeWrapper < UInt64 , [ UInt64 ] > , at position: Int ) -> [ ParentState ] {
305+ guard position >= 0 && position < children. count else {
306+ return parents
307+ }
287308 children [ position] . childPropertiesUInt64Array [ property] ? . isDirty = true
288309 return parents
289310 }
290311
291312 internal mutating func markChildDirty( property: MetatypeWrapper < Duration , Duration > , at position: Int ) -> [ ParentState ] {
313+ guard position >= 0 && position < children. count else {
314+ return parents
315+ }
292316 children [ position] . childPropertiesDuration [ property] ? . isDirty = true
293317 return parents
294318 }
295319
296320 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+ }
297324 children [ position] . totalFileCount. isDirty = true
298325 return parents
299326 }
300327
301328 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+ }
302332 children [ position] . completedFileCount. isDirty = true
303333 return parents
304334 }
305335
306336 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+ }
307340 children [ position] . totalByteCount. isDirty = true
308341 return parents
309342 }
310343
311344 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+ }
312348 children [ position] . completedByteCount. isDirty = true
313349 return parents
314350 }
315351
316352 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+ }
317356 children [ position] . throughput. isDirty = true
318357 return parents
319358 }
320359
321360 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+ }
322364 children [ position] . estimatedTimeRemaining. isDirty = true
323365 return parents
324366 }
0 commit comments