Browse Source

fix lock unlock directory e2e

Marino Faggiana 7 years ago
parent
commit
18edeb9c20
2 changed files with 20 additions and 8 deletions
  1. 8 4
      iOSClient/Main/CCMain.m
  2. 12 4
      iOSClient/Security/NCEntoToEndInterface.swift

+ 8 - 4
iOSClient/Main/CCMain.m

@@ -4027,8 +4027,10 @@
                                     handler:^(AHKActionSheet *as) {
                                         
                                         dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
-                                           if ([app.endToEndInterface markEndToEndFolderEncrypted:app.activeUrl fileID:_metadata.fileID token:nil])
-                                               [self readFolder:self.serverUrl];
+                                           if ([app.endToEndInterface markEndToEndFolderEncrypted:app.activeUrl fileID:_metadata.fileID serverUrl:[NSString stringWithFormat:@"%@/%@", self.serverUrl, _metadata.fileName]])
+                                               dispatch_async(dispatch_get_main_queue(), ^{
+                                                   [self readFolder:self.serverUrl];
+                                               });
                                         });
                                     }];
         }
@@ -4043,8 +4045,10 @@
                                     handler:^(AHKActionSheet *as) {
                                         
                                         dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
-                                            if ([app.endToEndInterface deletemarkEndToEndFolderEncrypted:app.activeUrl fileID:_metadata.fileID token:nil])
-                                                [self readFolder:self.serverUrl];
+                                            if ([app.endToEndInterface deletemarkEndToEndFolderEncrypted:app.activeUrl fileID:_metadata.fileID serverUrl:[NSString stringWithFormat:@"%@/%@", self.serverUrl, _metadata.fileName]])
+                                                dispatch_async(dispatch_get_main_queue(), ^{
+                                                    [self readFolder:self.serverUrl];
+                                                });
                                         });
                                     }];
         }

+ 12 - 4
iOSClient/Security/NCEntoToEndInterface.swift

@@ -344,9 +344,9 @@ class NCEntoToEndInterface : NSObject, OCNetworkingDelegate  {
     // MARK: Manage Mark/Delete Encrypted Folder
     // --------------------------------------------------------------------------------------------
     
-    @objc func markEndToEndFolderEncrypted(_ url: String, fileID: String, token: String?) -> Bool {
+    @objc func markEndToEndFolderEncrypted(_ url: String, fileID: String, serverUrl: String) -> Bool {
         
-        var token : NSString? = token as NSString?
+        var token =  NCManageDatabase.sharedInstance.getDirectoryTokenLock(serverUrl: serverUrl) as NSString?
 
         if let error = NCNetworkingSync.sharedManager().lockEnd(toEndFolderEncrypted: appDelegate.activeUser, userID: appDelegate.activeUserID, password: appDelegate.activePassword, url: url , fileID: fileID, token: &token) as NSError? {
             
@@ -355,6 +355,8 @@ class NCEntoToEndInterface : NSObject, OCNetworkingDelegate  {
             return false
         }
         
+        NCManageDatabase.sharedInstance.setDirectoryTokenLock(serverUrl: serverUrl, token: token! as String)
+        
         if let error = NCNetworkingSync.sharedManager().markEnd(toEndFolderEncrypted: appDelegate.activeUser, userID: appDelegate.activeUserID, password: appDelegate.activePassword, url: url, fileID: fileID) as NSError? {
             
             appDelegate.messageNotification("E2E Mark folder as encrypted", description: error.localizedDescription+" code \(error.code)", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: error.code)
@@ -369,12 +371,14 @@ class NCEntoToEndInterface : NSObject, OCNetworkingDelegate  {
             return false
         }
         
+        NCManageDatabase.sharedInstance.setDirectoryTokenLock(serverUrl: serverUrl, token: "")
+        
         return true
     }
     
-    @objc func deletemarkEndToEndFolderEncrypted(_ url: String, fileID: String, token: String?) -> Bool {
+    @objc func deletemarkEndToEndFolderEncrypted(_ url: String, fileID: String, serverUrl: String) -> Bool {
         
-        var token : NSString? = token as NSString?
+        var token =  NCManageDatabase.sharedInstance.getDirectoryTokenLock(serverUrl: serverUrl) as NSString?
         
         if let error = NCNetworkingSync.sharedManager().lockEnd(toEndFolderEncrypted: appDelegate.activeUser, userID: appDelegate.activeUserID, password: appDelegate.activePassword, url: url , fileID: fileID, token: &token) as NSError? {
             
@@ -383,6 +387,8 @@ class NCEntoToEndInterface : NSObject, OCNetworkingDelegate  {
             return false
         }
         
+        NCManageDatabase.sharedInstance.setDirectoryTokenLock(serverUrl: serverUrl, token: token! as String)
+        
         if let error = NCNetworkingSync.sharedManager().deletemarkEnd(toEndFolderEncrypted: appDelegate.activeUser, userID: appDelegate.activeUserID, password: appDelegate.activePassword, url: url, fileID: fileID) as NSError? {
             
             appDelegate.messageNotification("E2E Remove mark folder as encrypted", description: error.localizedDescription+" code \(error.code)", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: error.code)
@@ -397,6 +403,8 @@ class NCEntoToEndInterface : NSObject, OCNetworkingDelegate  {
             return false
         }
         
+        NCManageDatabase.sharedInstance.setDirectoryTokenLock(serverUrl: serverUrl, token: "")
+        
         return true
     }