Do not copy pause, cancel, and resuming handlers in Progress extension copyCurrentStateToProgress by default

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2023-03-15 12:09:33 +01:00
parent 5e8d7217a9
commit a7616502ae
No known key found for this signature in database
GPG key ID: C839200C384636B0

View file

@ -15,9 +15,13 @@
import Foundation
extension Progress {
func copyCurrentStateToProgress(_ otherProgress: Progress) {
otherProgress.cancellationHandler = self.cancellationHandler
otherProgress.pausingHandler = self.pausingHandler
func copyCurrentStateToProgress(_ otherProgress: Progress, includeHandlers: Bool = false) {
if includeHandlers {
otherProgress.cancellationHandler = self.cancellationHandler
otherProgress.pausingHandler = self.pausingHandler
otherProgress.resumingHandler = self.resumingHandler
}
otherProgress.totalUnitCount = self.totalUnitCount
otherProgress.completedUnitCount = self.completedUnitCount
otherProgress.estimatedTimeRemaining = self.estimatedTimeRemaining
@ -38,9 +42,9 @@ extension Progress {
}
}
func copyOfCurrentState() -> Progress {
func copyOfCurrentState(includeHandlers: Bool = false) -> Progress {
let newProgress = Progress()
copyCurrentStateToProgress(newProgress)
copyCurrentStateToProgress(newProgress, includeHandlers: includeHandlers)
return newProgress
}
}