Jelajahi Sumber

Merge pull request #2206 from nextcloud/452

Auto upload - V 4.5.3
Marino Faggiana 2 tahun lalu
induk
melakukan
2211ad2652

+ 4 - 4
Nextcloud.xcodeproj/project.pbxproj

@@ -3607,7 +3607,7 @@
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				COPY_PHASE_STRIP = NO;
-				CURRENT_PROJECT_VERSION = 3;
+				CURRENT_PROJECT_VERSION = 0;
 				DEVELOPMENT_TEAM = NKUJUXUJ3B;
 				ENABLE_STRICT_OBJC_MSGSEND = YES;
 				ENABLE_TESTABILITY = YES;
@@ -3631,7 +3631,7 @@
 					"@executable_path/Frameworks",
 					"@executable_path/../../Frameworks",
 				);
-				MARKETING_VERSION = 4.5.1;
+				MARKETING_VERSION = 4.5.2;
 				ONLY_ACTIVE_ARCH = YES;
 				OTHER_LDFLAGS = "";
 				SDKROOT = iphoneos;
@@ -3670,7 +3670,7 @@
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				COPY_PHASE_STRIP = NO;
-				CURRENT_PROJECT_VERSION = 3;
+				CURRENT_PROJECT_VERSION = 0;
 				DEVELOPMENT_TEAM = NKUJUXUJ3B;
 				ENABLE_STRICT_OBJC_MSGSEND = YES;
 				ENABLE_TESTABILITY = YES;
@@ -3692,7 +3692,7 @@
 					"@executable_path/Frameworks",
 					"@executable_path/../../Frameworks",
 				);
-				MARKETING_VERSION = 4.5.1;
+				MARKETING_VERSION = 4.5.2;
 				ONLY_ACTIVE_ARCH = YES;
 				OTHER_LDFLAGS = "";
 				SDKROOT = iphoneos;

+ 1 - 0
iOSClient/AppDelegate.swift

@@ -59,6 +59,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
     var networkingProcessUpload: NCNetworkingProcessUpload?
     var shares: [tableShare] = []
     var timerErrorNetworking: Timer?
+    var timerProcess: Timer?
 
     private var privacyProtectionWindow: UIWindow?
 

+ 16 - 9
iOSClient/Networking/NCNetworkingProcessUpload.swift

@@ -27,7 +27,7 @@ import Photos
 
 class NCNetworkingProcessUpload: NSObject {
 
-    var timerProcess: Timer?
+    let appDelegate = UIApplication.shared.delegate as? AppDelegate
 
     override init() {
         super.init()
@@ -35,18 +35,18 @@ class NCNetworkingProcessUpload: NSObject {
     }
 
     private func startProcess() {
-        if timerProcess?.isValid ?? false {
+        if appDelegate?.timerProcess?.isValid ?? false {
             DispatchQueue.main.async { self.process() }
         }
     }
 
     func startTimer() {
-        timerProcess?.invalidate()
-        timerProcess = Timer.scheduledTimer(timeInterval: 5, target: self, selector: #selector(process), userInfo: nil, repeats: true)
+        appDelegate?.timerProcess?.invalidate()
+        appDelegate?.timerProcess = Timer.scheduledTimer(timeInterval: 5, target: self, selector: #selector(process), userInfo: nil, repeats: true)
     }
 
     func stopTimer() {
-        timerProcess?.invalidate()
+        appDelegate?.timerProcess?.invalidate()
     }
 
     @objc private func process() {
@@ -54,6 +54,7 @@ class NCNetworkingProcessUpload: NSObject {
         guard let account = NCManageDatabase.shared.getActiveAccount(), UIApplication.shared.applicationState == .active else { return }
         let metadatasUpload = NCManageDatabase.shared.getMetadatas(predicate: NSPredicate(format: "status == %d OR status == %d", NCGlobal.shared.metadataStatusInUpload, NCGlobal.shared.metadataStatusUploading))
         if metadatasUpload.filter({ $0.chunk || $0.e2eEncrypted }).count > 0 { return }
+        let isWiFi = NCNetworking.shared.networkReachability == NKCommon.typeReachability.reachableEthernetOrWiFi
 
         stopTimer()
 
@@ -102,14 +103,20 @@ class NCNetworkingProcessUpload: NSObject {
                         if metadatas.isEmpty {
                             NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
                         }
-                        for metadata in metadatas where counterUpload < NCGlobal.shared.maxConcurrentOperationUpload {
-                            let isWiFi = NCNetworking.shared.networkReachability == NKCommon.typeReachability.reachableEthernetOrWiFi
-                            if metadata.session == NCNetworking.shared.sessionIdentifierBackgroundWWan && !isWiFi { continue }
+                        for metadata in metadatas {
+
+                            if !isWiFi && metadata.session == NCNetworking.shared.sessionIdentifierBackgroundWWan {
+                                continue
+                            }
+
                             if let metadata = NCManageDatabase.shared.setMetadataStatus(ocId: metadata.ocId, status: NCGlobal.shared.metadataStatusInUpload) {
                                 NCNetworking.shared.upload(metadata: metadata)
                             }
+
                             if metadata.e2eEncrypted || metadata.chunk {
+                                // Only one
                                 counterUpload = NCGlobal.shared.maxConcurrentOperationUpload
+                                break
                             } else {
                                 counterUpload += 1
                             }
@@ -130,7 +137,7 @@ class NCNetworkingProcessUpload: NSObject {
              
             // verify delete Asset Local Identifiers in auto upload (DELETE Photos album)
             DispatchQueue.main.async {
-                if UIApplication.shared.applicationState == .active && counterUpload == 0 && !(UIApplication.shared.delegate as! AppDelegate).isPasscodePresented() {
+                if counterUpload == 0 && !(UIApplication.shared.delegate as! AppDelegate).isPasscodePresented() {
                     self.deleteAssetLocalIdentifiers(account: account.account) {
                         self.startTimer()
                     }