浏览代码

coding

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
Marino Faggiana 2 年之前
父节点
当前提交
01ecd0ebf3
共有 1 个文件被更改,包括 27 次插入11 次删除
  1. 27 11
      iOSClient/AppDelegate.swift

+ 27 - 11
iOSClient/AppDelegate.swift

@@ -63,6 +63,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
     var errorITMS90076: Bool = false
 
     private var privacyProtectionWindow: UIWindow?
+    private var autoUploadInprogress: Bool = false
     
     func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
 
@@ -242,8 +243,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         }
         
         // Initialize Auto upload
-        NCAutoUpload.shared.initAutoUpload(viewController: nil) { items in
-            NKCommon.shared.writeLog("Initialize Auto upload with \(items) uploads")
+        if !autoUploadInprogress {
+            NCAutoUpload.shared.initAutoUpload(viewController: nil) { items in
+                NKCommon.shared.writeLog("Initialize Auto upload with \(items) uploads")
+                self.autoUploadInprogress = false
+            }
         }
 
         // Required unsubscribing / subscribing
@@ -327,8 +331,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         NCPushNotification.shared().pushNotification()
 
         // Start Auto Upload
-        NCAutoUpload.shared.initAutoUpload(viewController: nil) { items in
-            NKCommon.shared.writeLog("Initialize Auto upload with \(items) uploads")
+        if !autoUploadInprogress {
+            autoUploadInprogress = true
+            NCAutoUpload.shared.initAutoUpload(viewController: nil) { items in
+                NKCommon.shared.writeLog("Initialize Auto upload with \(items) uploads")
+                self.autoUploadInprogress = false
+            }
         }
 
         // Start services
@@ -392,9 +400,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         
         NKCommon.shared.writeLog("Start handler refresh task [Auto upload]")
 
-        NCAutoUpload.shared.initAutoUpload(viewController: nil) { items in
-            NKCommon.shared.writeLog("Completition handler refresh task [Auto upload] with \(items) uploads")
-            task.setTaskCompleted(success: true)
+        if !autoUploadInprogress {
+            autoUploadInprogress = true
+            NCAutoUpload.shared.initAutoUpload(viewController: nil) { items in
+                NKCommon.shared.writeLog("Completition handler refresh task [Auto upload] with \(items) uploads")
+                self.autoUploadInprogress = false
+                task.setTaskCompleted(success: true)
+            }
         }
     }
 
@@ -407,10 +419,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         }
 
         NKCommon.shared.writeLog("Start handler processing task [Auto upload]")
-        
-        NCAutoUpload.shared.initAutoUpload(viewController: nil) { items in
-            NKCommon.shared.writeLog("Completition handler procesing task [Auto upload] with \(items) uploads")
-            task.setTaskCompleted(success: true)
+
+        if !autoUploadInprogress {
+            autoUploadInprogress = true
+            NCAutoUpload.shared.initAutoUpload(viewController: nil) { items in
+                NKCommon.shared.writeLog("Completition handler procesing task [Auto upload] with \(items) uploads")
+                self.autoUploadInprogress = false
+                task.setTaskCompleted(success: true)
+            }
         }
     }