marinofaggiana 4 years ago
parent
commit
357033b473

+ 1 - 47
Share/NCSelectDestination.m

@@ -228,7 +228,7 @@
 
 - (void)readFolder
 {
-    [[NCNetworking sharedInstance] readFolderWithServerUrl:_serverUrl account:activeAccount completion:^(NSString *account, tableMetadata *metadataFolder, NSInteger errorCode, NSString *errorDescription) {
+    [[NCNetworking sharedInstance] readFolderWithServerUrl:_serverUrl account:activeAccount completion:^(NSString *account, tableMetadata *metadataFolder, NSArray *metadatas, NSInteger errorCode, NSString *errorDescription) {
         
         if (errorCode == 0) {
             self.move.enabled = true;
@@ -242,52 +242,6 @@
     
     _loadingFolder = YES;
     [self.tableView reloadData];
-    
-    /*
-    [[NCCommunication sharedInstance] readFileOrFolderWithServerUrlFileName:_serverUrl depth:@"1" showHiddenFiles:[CCUtility getShowHiddenFiles] account:activeAccount completionHandler:^(NSString *account, NSArray<NCFile *> *files, NSInteger errorCode, NSString *errorDecription) {
-        
-        if (errorCode == 0 && files != nil) {
-
-            // Metadata conversion
-            tableMetadata *metadataFolder = [tableMetadata new];
-            NSArray *metadatas = [[NCNetworking sharedInstance] convertFilesToMetadatas:files metadataFolder:&metadataFolder];
-        
-            // Update directory etag
-            [[NCManageDatabase sharedInstance] setDirectoryWithServerUrl:_serverUrl serverUrlTo:nil etag:metadataFolder.etag ocId:metadataFolder.ocId encrypted:metadataFolder.e2eEncrypted richWorkspace:nil account:account];
-            
-            // Delete metadata
-            [[NCManageDatabase sharedInstance] deleteMetadataWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@ AND status == %d", account, _serverUrl, k_metadataStatusNormal]];
-            
-            // In download
-            NSArray *metadatasInDownload = [[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@ AND (status == %d OR status == %d OR status == %d OR status == %d)", account, _serverUrl, k_metadataStatusWaitDownload, k_metadataStatusInDownload, k_metadataStatusDownloading, k_metadataStatusDownloadError] sorted:nil ascending:NO];
-            
-            // Insert in Database
-            [[NCManageDatabase sharedInstance] addMetadatas:metadatas];
-            
-            // reinsert metadatas in Download
-            if (metadatasInDownload) {
-                [[NCManageDatabase sharedInstance] addMetadatas:metadatasInDownload];
-            }
-                               
-        } else {
-            
-            self.move.enabled = NO;
-            
-            UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_error_",nil) message:errorDecription preferredStyle:UIAlertControllerStyleAlert];
-            
-            [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
-            }]];
-            
-            [self presentViewController:alertController animated:YES completion:nil];
-        }
-        
-        _loadingFolder = NO;
-        [self.tableView reloadData];
-    }];
-    
-    _loadingFolder = YES;
-    [self.tableView reloadData];
-    */
 }
 
     

+ 4 - 8
iOSClient/Main/CCMain.m

@@ -1288,7 +1288,7 @@
 
     [self tableViewReloadData];
     
-    [[NCNetworking sharedInstance] readFolderWithServerUrl:serverUrl account:appDelegate.activeAccount completion:^(NSString *account, tableMetadata *metadataFolder, NSInteger errorCode, NSString *errorDescription) {
+    [[NCNetworking sharedInstance] readFolderWithServerUrl:serverUrl account:appDelegate.activeAccount completion:^(NSString *account, tableMetadata *metadataFolder, NSArray *metadatas, NSInteger errorCode, NSString *errorDescription) {
         
         [refreshControl endRefreshing];
 
@@ -1300,13 +1300,9 @@
             
 
             // File is changed ??
-            /*
-            if (!self.searchController.isActive && metadatas) {
-                dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
-                    [[CCSynchronize sharedSynchronize] verifyChangeMedatas:metadatas serverUrl:serverUrl account:account withDownload:NO];
-                });
-            }
-            */
+            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
+                [[CCSynchronize sharedSynchronize] verifyChangeMedatas:metadatas serverUrl:serverUrl account:account withDownload:NO];
+            });
             
             // E2EE Is encrypted folder get metadata
             if (isFolderEncrypted) {

+ 4 - 4
iOSClient/Networking/NCNetworking.swift

@@ -228,7 +228,7 @@ import NCCommunication
     
     //MARK: - WebDav
     
-    @objc func readFolder(serverUrl: String, account: String, completion: @escaping (_ account: String, _ metadataFolder: tableMetadata?, _ errorCode: Int, _ errorDescription: String)->()) {
+    @objc func readFolder(serverUrl: String, account: String, completion: @escaping (_ account: String, _ metadataFolder: tableMetadata?, _ metadatas: [tableMetadata]?, _ errorCode: Int, _ errorDescription: String)->()) {
         
         NCCommunication.sharedInstance.readFileOrFolder(serverUrlFileName: serverUrl, depth: "1", showHiddenFiles: CCUtility.getShowHiddenFiles(), account: account) { (account, files, errorCode, errorDescription) in
             
@@ -252,7 +252,7 @@ import NCCommunication
 
                 // Add metadata
                 let metadataFolderInserted = NCManageDatabase.sharedInstance.addMetadata(metadataFolder)
-                NCManageDatabase.sharedInstance.addMetadatas(metadatas)
+                let metadatasInserted = NCManageDatabase.sharedInstance.addMetadatas(metadatas)
                  
                 if metadatasInDownload != nil {
                     NCManageDatabase.sharedInstance.addMetadatas(metadatasInDownload!)
@@ -261,7 +261,7 @@ import NCCommunication
                     NCManageDatabase.sharedInstance.addMetadatas(metadatasInUpload!)
                 }
                 
-                completion(account, metadataFolderInserted, errorCode, "")
+                completion(account, metadataFolderInserted, metadatasInserted, errorCode, "")
                 
             } else {
                 
@@ -270,7 +270,7 @@ import NCCommunication
                 
                 NCContentPresenter.shared.messageNotification("_error_", description: errorDescription, delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: errorCode)
                 
-                completion(account, nil, errorCode, errorDescription!)
+                completion(account, nil, nil, errorCode, errorDescription!)
             }
         }
     }

+ 1 - 1
iOSClient/Select/NCSelect.swift

@@ -804,7 +804,7 @@ extension NCSelect {
         networkInProgress = true
         collectionView.reloadData()
         
-        NCNetworking.sharedInstance.readFolder(serverUrl: serverUrl, account: appDelegate.activeAccount) { (account, metadataFolder, errorCode, errorDescription) in
+        NCNetworking.sharedInstance.readFolder(serverUrl: serverUrl, account: appDelegate.activeAccount) { (account, metadataFolder, metadatas, errorCode, errorDescription) in
             
             self.networkInProgress = false
             self.loadDatasource(withLoadFolder: false)