diff options
author | Marino Faggiana <marino@marinofaggiana.com> | 2022-09-30 15:09:59 +0300 |
---|---|---|
committer | Marino Faggiana <marino@marinofaggiana.com> | 2022-09-30 15:09:59 +0300 |
commit | 4d302e9270c32824402bbc95184f7507f3b6aa67 (patch) | |
tree | 88056bb851569cab0b9c445d443dd8b3ca477a9f | |
parent | 15f21fc067c83777617925c8e778f6cf4a5d6ffc (diff) |
TEST
Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
-rw-r--r-- | iOSClient/AppDelegate.swift | 48 | ||||
-rw-r--r-- | iOSClient/Networking/NCNetworking.swift | 13 |
2 files changed, 22 insertions, 39 deletions
diff --git a/iOSClient/AppDelegate.swift b/iOSClient/AppDelegate.swift index 8508c9b63..bed64b30a 100644 --- a/iOSClient/AppDelegate.swift +++ b/iOSClient/AppDelegate.swift @@ -63,8 +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 { let userAgent = CCUtility.getUserAgent() as String @@ -243,13 +242,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD } // Initialize Auto upload - if !autoUploadInprogress { - NCAutoUpload.shared.initAutoUpload(viewController: nil) { items in - NKCommon.shared.writeLog("Initialize Auto upload with \(items) uploads") - self.autoUploadInprogress = false - } - } else { - NKCommon.shared.writeLog("Auto upload already in progress.") + NCAutoUpload.shared.initAutoUpload(viewController: nil) { items in + NKCommon.shared.writeLog("Initialize Auto upload with \(items) uploads") } // Required unsubscribing / subscribing @@ -333,14 +327,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD NCPushNotification.shared().pushNotification() // Start Auto Upload - if !autoUploadInprogress { - autoUploadInprogress = true - NCAutoUpload.shared.initAutoUpload(viewController: nil) { items in - NKCommon.shared.writeLog("Initialize Auto upload with \(items) uploads") - self.autoUploadInprogress = false - } - } else { - NKCommon.shared.writeLog("Auto upload already in progress.") + NCAutoUpload.shared.initAutoUpload(viewController: nil) { items in + NKCommon.shared.writeLog("Initialize Auto upload with \(items) uploads") } // Start services @@ -403,16 +391,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD } NKCommon.shared.writeLog("Start handler refresh task [Auto upload]") - - 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) - } - } else { - NKCommon.shared.writeLog("Auto upload already in progress.") + + NCAutoUpload.shared.initAutoUpload(viewController: nil) { items in + NKCommon.shared.writeLog("Completition handler refresh task [Auto upload] with \(items) uploads") + task.setTaskCompleted(success: true) } } @@ -426,15 +408,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD NKCommon.shared.writeLog("Start handler processing task [Auto upload]") - 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) - } - } else { - NKCommon.shared.writeLog("Auto upload already in progress.") + NCAutoUpload.shared.initAutoUpload(viewController: nil) { items in + NKCommon.shared.writeLog("Completition handler procesing task [Auto upload] with \(items) uploads") + task.setTaskCompleted(success: true) } } diff --git a/iOSClient/Networking/NCNetworking.swift b/iOSClient/Networking/NCNetworking.swift index 2087dbb06..e10f45f8a 100644 --- a/iOSClient/Networking/NCNetworking.swift +++ b/iOSClient/Networking/NCNetworking.swift @@ -423,9 +423,16 @@ import Photos } } } else { - uploadFileInBackground(metadata: metadata, start: start) { error in - DispatchQueue.main.async { - completion(error) + isInTaskUploadBackground(fileName: metadata.fileName) { exists in + if exists { + NKCommon.shared.writeLog("[INFO] Upload already in progress.") + completion(NKError(errorCode: 0, errorDescription: "")) + } else { + self.uploadFileInBackground(metadata: metadata, start: start) { error in + DispatchQueue.main.async { + completion(error) + } + } } } } |