Эх сурвалжийг харах

detect e2ee in queue for unlock

Marino Faggiana 6 жил өмнө
parent
commit
1f86d4154e

+ 13 - 8
iOSClient/AppDelegate.m

@@ -1251,21 +1251,26 @@
     tableMetadata *metadataForUpload, *metadataForDownload;
     long counterDownload = 0, counterUpload = 0;
     NSUInteger sizeDownload = 0, sizeUpload = 0;
-    
+    BOOL isE2EE = false;
+
     // Test Maintenance
     if (self.maintenanceMode)
         return;
     
-    // E2EE : not in background
-    if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateBackground) {
-        tableMetadata *metadata = [[NCManageDatabase sharedInstance] getMetadataWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND (status == %d OR status == %d)", self.activeAccount, k_metadataStatusInUpload, k_metadataStatusUploading]];
-        if (metadata) {
-            tableDirectory *directory = [[NCManageDatabase sharedInstance] getTableDirectoryWithPredicate:[NSPredicate predicateWithFormat:@"directoryID == %@ AND e2eEncrypted == 1", metadata.directoryID]];
-            if (directory != nil)
-                return;
+    // Detect E2EE
+    tableMetadata *metadata = [[NCManageDatabase sharedInstance] getMetadataWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND (status == %d OR status == %d)", self.activeAccount, k_metadataStatusInUpload, k_metadataStatusUploading]];
+    if (metadata) {
+        tableDirectory *directory = [[NCManageDatabase sharedInstance] getTableDirectoryWithPredicate:[NSPredicate predicateWithFormat:@"directoryID == %@ AND e2eEncrypted == 1", metadata.directoryID]];
+        if (directory != nil) {
+            isE2EE = true;
         }
     }
     
+    // E2EE : not in background
+    if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateBackground && isE2EE) {
+        return;
+    }
+    
     // Stop Timer
     [_timerProcessAutoDownloadUpload invalidate];
     NSArray *metadatasDownload = [[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND (status == %d OR status == %d)", self.activeAccount, k_metadataStatusInDownload, k_metadataStatusDownloading] sorted:nil ascending:true];

+ 5 - 2
iOSClient/Networking/CCNetworking.m

@@ -1064,7 +1064,7 @@
     NSString *errorMessage = @"";
     BOOL isE2EEDirectory = false;
     
-    // E2EE Directory ?
+    // is this a E2EE Directory ?
     if ([CCUtility isFolderEncrypted:serverUrl account:_activeAccount] && [CCUtility isEndToEndEnabled:_activeAccount]) {
         isE2EEDirectory = true;
     }
@@ -1176,8 +1176,11 @@
         [[NCManageDatabase sharedInstance] addActivityClient:metadata.fileNameView fileID:fileID action:k_activityDebugActionUpload selector:metadata.sessionSelector note:serverUrl type:k_activityTypeSuccess verbose:k_activityVerboseDefault activeUrl:_activeUrl];
     }
     
+    // Detect E2EE
+    tableMetadata *e2eeMetadataInSession = [[NCManageDatabase sharedInstance] getMetadataWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND directoryID == %@ AND e2eEncrypted == 1 AND (status == %d OR status == %d)", _activeAccount, metadata.directoryID, k_metadataStatusInUpload, k_metadataStatusUploading]];
+    
     // E2EE : UNLOCK
-    if (isE2EEDirectory) {
+    if (isE2EEDirectory && e2eeMetadataInSession == nil) {
         
         tableE2eEncryptionLock *tableLock = [[NCManageDatabase sharedInstance] getE2ETokenLockWithServerUrl:serverUrl];