Do not copy pause, cancel, and resuming handlers in Progress extension copyCurrentSta...
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Wed, 15 Mar 2023 11:09:33 +0000 (12:09 +0100)
committerClaudio Cambra <claudio.cambra@nextcloud.com>
Fri, 12 May 2023 05:28:45 +0000 (13:28 +0800)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Extensions/Progress+Extensions.swift

index 97123fd901428d6e454b4ed807337b55a4f489d5..926fed83c02fb7d3f62de844a936095911801638 100644 (file)
 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
     }
 }