marinofaggiana há 4 anos atrás
pai
commit
3bdb52ea79

+ 1 - 1
Nextcloud.xcodeproj/project.pbxproj

@@ -973,9 +973,9 @@
 			isa = PBXGroup;
 			children = (
 				F75A9EE523796C6F0044CFCE /* NCNetworking.swift */,
+				F785EE9C246196DF00B3F945 /* NCNetworkingE2EE.swift */,
 				F70D8D8024A4A9BF000A5756 /* NCNetworkingAutoUpload.swift */,
 				F7D96FCB246ED7E100536D73 /* NCNetworkingCheckRemoteUser.swift */,
-				F785EE9C246196DF00B3F945 /* NCNetworkingE2EE.swift */,
 				F75B0ABC244C4DBB00E58DCA /* NCNetworkingNotificationCenter.swift */,
 				F72A47EB2487B06B005AD489 /* NCOperationQueue.swift */,
 				F755BD9A20594AC7008C5FBB /* NCService.swift */,

+ 0 - 1
iOSClient/Networking/NCNetworking.swift

@@ -884,7 +884,6 @@ import Queuer
                 }
                 
                 NotificationCenter.default.postOnMainThread(name: k_notificationCenter_deleteFile, userInfo: ["metadata": metadata, "onlyLocal": false])
-                
             }
             
             completion(errorCode, errorDescription)

+ 43 - 27
iOSClient/Networking/NCNetworkingE2EE.swift

@@ -55,6 +55,10 @@ import Alamofire
                 NCCommunication.shared.createFolder(fileNameFolderUrl, addCustomHeaders: ["e2e-token" : e2eToken!]) { (account, ocId, date, errorCode, errorDescription) in
                     if errorCode == 0 {
                         guard let fileId = NCUtility.shared.ocIdToFileId(ocId: ocId) else {
+                            // unlock
+                            if let tableLock = NCManageDatabase.sharedInstance.getE2ETokenLock(account: account, serverUrl: serverUrl) {
+                                NCCommunication.shared.lockE2EEFolder(fileId: tableLock.fileId, e2eToken: tableLock.e2eToken, method: "DELETE") { (_, _, _, _) in }
+                            }
                             completion(Int(k_CCErrorInternalError), "Error convert ocId")
                             return
                         }
@@ -87,16 +91,32 @@ import Alamofire
                                 let _ = NCManageDatabase.sharedInstance.addE2eEncryption(object)
                                 
                                 self.sendE2EMetadata(account: account, serverUrl: serverUrl, fileNameRename: nil, fileNameNewRename: nil, deleteE2eEncryption: nil, urlBase: urlBase) { (e2eToken, errorCode, errorDescription) in
-                                    
+                                    // unlock
+                                    if let tableLock = NCManageDatabase.sharedInstance.getE2ETokenLock(account: account, serverUrl: serverUrl) {
+                                        NCCommunication.shared.lockE2EEFolder(fileId: tableLock.fileId, e2eToken: tableLock.e2eToken, method: "DELETE") { (_, _, _, _) in }
+                                    }
+                                    if errorCode == 0 {
+                                        if let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(ocId) {
+                                            NotificationCenter.default.postOnMainThread(name: k_notificationCenter_createFolder, userInfo: ["metadata": metadata])
+                                        }
+                                    }
                                     completion(errorCode, errorDescription ?? "")
                                 }
                                 
                             } else {
+                                // unlock
+                                if let tableLock = NCManageDatabase.sharedInstance.getE2ETokenLock(account: account, serverUrl: serverUrl) {
+                                    NCCommunication.shared.lockE2EEFolder(fileId: tableLock.fileId, e2eToken: tableLock.e2eToken, method: "DELETE") { (_, _, _, _) in }
+                                }
                                 completion(errorCode, errorDescription)
                             }
                         }
                         
                     } else {
+                        // unlock
+                        if let tableLock = NCManageDatabase.sharedInstance.getE2ETokenLock(account: account, serverUrl: serverUrl) {
+                            NCCommunication.shared.lockE2EEFolder(fileId: tableLock.fileId, e2eToken: tableLock.e2eToken, method: "DELETE") { (_, _, _, _) in }
+                        }
                         completion(errorCode, errorDescription)
                     }
                 }
@@ -118,14 +138,24 @@ import Alamofire
                     let home = NCUtility.shared.getHomeServer(urlBase: metadata.urlBase, account: metadata.account)
                     if metadata.serverUrl != home {
                         self.sendE2EMetadata(account: metadata.account, serverUrl: metadata.serverUrl, fileNameRename: nil, fileNameNewRename: nil, deleteE2eEncryption: deleteE2eEncryption, urlBase: urlBase) { (e2eToken, errorCode, errorDescription) in
-                            self.NotificationPost(name: k_notificationCenter_deleteFile, account: metadata.account, serverUrl: metadata.serverUrl, userInfo: ["metadata": metadata, "onlyLocal": false, "errorCode": errorCode], errorDescription: errorDescription, completion: completion)
+                            // unlock
+                            if let tableLock = NCManageDatabase.sharedInstance.getE2ETokenLock(account: metadata.account, serverUrl: metadata.serverUrl) {
+                                NCCommunication.shared.lockE2EEFolder(fileId: tableLock.fileId, e2eToken: tableLock.e2eToken, method: "DELETE") { (_, _, _, _) in }
+                            }
+                            NotificationCenter.default.postOnMainThread(name: k_notificationCenter_deleteFile, userInfo: ["metadata": metadata, "onlyLocal": false])
+                            completion(errorCode, errorDescription ?? "")
                         }
                     } else {
-                        self.NotificationPost(name: k_notificationCenter_deleteFile, account: metadata.account, serverUrl: metadata.serverUrl, userInfo: ["metadata": metadata, "onlyLocal": false, "errorCode": errorCode], errorDescription: errorDescription, completion: completion)
+                        // unlock
+                        if let tableLock = NCManageDatabase.sharedInstance.getE2ETokenLock(account: metadata.account, serverUrl: metadata.serverUrl) {
+                            NCCommunication.shared.lockE2EEFolder(fileId: tableLock.fileId, e2eToken: tableLock.e2eToken, method: "DELETE") { (_, _, _, _) in }
+                        }
+                        NotificationCenter.default.postOnMainThread(name: k_notificationCenter_deleteFile, userInfo: ["metadata": metadata, "onlyLocal": false])
+                        completion(errorCode, errorDescription)
                     }
                 }
             } else {
-                self.NotificationPost(name: k_notificationCenter_deleteFile, account: metadata.account, serverUrl: metadata.serverUrl, userInfo: ["metadata": metadata, "onlyLocal": false, "errorCode": errorCode], errorDescription: errorDescription, completion: completion)
+                completion(errorCode, errorDescription ?? "")
             }
         }
     }
@@ -137,7 +167,7 @@ import Alamofire
         // verify if exists the new fileName
         if NCManageDatabase.sharedInstance.getE2eEncryption(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND fileName == %@", metadata.account, metadata.serverUrl, fileNameNew)) != nil {
             
-            self.NotificationPost(name: k_notificationCenter_renameFile, account: metadata.account, serverUrl: metadata.serverUrl, userInfo: ["metadata": metadata, "errorCode": Int(k_CCErrorInternalError)], errorDescription: "_file_already_exists_", completion: completion)
+            completion(Int(k_CCErrorInternalError), "_file_already_exists_")
 
         } else {
             
@@ -152,10 +182,16 @@ import Alamofire
                     do {
                         try FileManager.default.moveItem(atPath: atPath, toPath: toPath)
                     } catch { }
+                    
+                    NotificationCenter.default.postOnMainThread(name: k_notificationCenter_renameFile, userInfo: ["metadata": metadata])
                 }
                 
-                NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
-                self.NotificationPost(name: k_notificationCenter_deleteFile, account: metadata.account, serverUrl: metadata.serverUrl, userInfo: ["metadata": metadata, "onlyLocal": false, "errorCode": errorCode], errorDescription: errorDescription, completion: completion)
+                // unlock
+                if let tableLock = NCManageDatabase.sharedInstance.getE2ETokenLock(account: metadata.account, serverUrl: metadata.serverUrl) {
+                    NCCommunication.shared.lockE2EEFolder(fileId: tableLock.fileId, e2eToken: tableLock.e2eToken, method: "DELETE") { (_, _, _, _) in }
+                }
+                
+                completion(errorCode, errorDescription)
             }
         }
     }
@@ -405,26 +441,6 @@ import Alamofire
             }
         }
     }
-    
-    //MARK: - Notification Post
-       
-    private func NotificationPost(name: String, account: String, serverUrl: String, userInfo: [AnyHashable : Any], errorDescription: Any?, completion: @escaping (_ errorCode: Int, _ errorDescription: String)->()) {
-        var userInfo = userInfo
-        DispatchQueue.main.async {
-            
-            // unlock
-            if let tableLock = NCManageDatabase.sharedInstance.getE2ETokenLock(account: account, serverUrl: serverUrl) {
-                NCCommunication.shared.lockE2EEFolder(fileId: tableLock.fileId, e2eToken: tableLock.e2eToken, method: "DELETE") { (_, _, _, _) in }
-            }
-            
-            if errorDescription == nil { userInfo["errorDescription"] = "" }
-            else { userInfo["errorDescription"] = NSLocalizedString(errorDescription as! String, comment: "") }
-               
-            NotificationCenter.default.postOnMainThread(name: name, userInfo: userInfo)
-               
-            completion(userInfo["errorCode"] as! Int, userInfo["errorDescription"] as! String)
-        }
-    }
 }
 
 

+ 1 - 1
iOSClient/Supporting Files/en.lproj/Localizable.strings

@@ -345,7 +345,7 @@
 "_access_photo_location_not_enabled_"       = "Access to Photos and Location not enabled";
 "_access_photo_location_not_enabled_msg_"   = "Please go to \"Settings\" and turn on \"Photo Access\" and \"Location Services\"";
 "_tutorial_photo_view_"                     = "No photos or videos uploaded yet";
-"_create_full_upload_"                      = "Creating archive… May take a long time. In this mode, keep the application active during the transfer as well";
+"_create_full_upload_"                      = "Creating archive… May take a long time. In this mode, keep the application active during the transfer as well.";
 "_error_createsubfolders_upload_"           = "Error creating subfolders";
 "_activate_autoupload_"                     = "Enable auto upload";
 "_remove_photo_CameraRoll_"                 = "Remove from camera roll";