瀏覽代碼

Check if sync is in progress

Marino Faggiana 8 年之前
父節點
當前提交
4021dec4ef
共有 3 個文件被更改,包括 46 次插入0 次删除
  1. 3 0
      iOSClient/AppDelegate.h
  2. 39 0
      iOSClient/AppDelegate.m
  3. 4 0
      iOSClient/Synchronization/CCSynchronization.m

+ 3 - 0
iOSClient/AppDelegate.h

@@ -187,7 +187,10 @@
 // Operation Networking
 - (void)cancelAllOperations;
 - (void)addNetworkingOperationQueue:(NSOperationQueue *)netQueue delegate:(id)delegate metadataNet:(CCMetadataNet *)metadataNet oneByOne:(BOOL)oneByOne;
+
+- (NSMutableArray *)verifyExistsInQueuesDownloadSelector:(NSString *)selector;
 - (NSMutableArray *)verifyExistsInQueuesUploadSelector:(NSString *)selector;
+
 - (void)loadTableAutomaticUploadForSelector:(NSString *)selector;
 
 - (void)dropAutomaticUploadWithSelector:(NSString *)selector;

+ 39 - 0
iOSClient/AppDelegate.m

@@ -404,6 +404,7 @@
     
     
     // ONLY BACKGROUND
+    
     if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateBackground) {
     
         // Verify Synchronized Folder
@@ -411,6 +412,7 @@
         NSLog(@"5 sec. %lu", (unsigned long)[metadatasNet count]);
 
     } else {
+        
     // ONLY FOREFROUND
     
     }
@@ -1066,6 +1068,43 @@
     [netQueue addOperation:operation];
 }
 
+- (NSMutableArray *)verifyExistsInQueuesDownloadSelector:(NSString *)selector
+{
+    NSMutableArray *metadatasNet = [[NSMutableArray alloc] init];
+    
+    /*** NEXTCLOUD OWNCLOUD ***/
+    
+    if ([app.typeCloud isEqualToString:typeCloudOwnCloud] || [app.typeCloud isEqualToString:typeCloudNextcloud]) {
+        
+        for (OCnetworking *operation in [self.netQueueDownload operations])
+            if ([operation.metadataNet.selector isEqualToString:selector])
+                [metadatasNet addObject:[operation.metadataNet copy]];
+        
+        for (OCnetworking *operation in [self.netQueueDownloadWWan operations])
+            if ([operation.metadataNet.selector isEqualToString:selector])
+                [metadatasNet addObject:[operation.metadataNet copy]];
+    }
+    
+#ifdef CC
+    
+    /*** DROPBOX ***/
+    
+    if ([app.typeCloud isEqualToString:typeCloudDropbox]) {
+        
+        for (DBnetworking *operation in [self.netQueueDownload operations])
+            if ([operation.metadataNet.selector isEqualToString:selector])
+                [metadatasNet addObject:operation.metadataNet];
+        
+        for (DBnetworking *operation in [self.netQueueDownloadWWan operations])
+            if ([operation.metadataNet.selector isEqualToString:selector])
+                [metadatasNet addObject:operation.metadataNet];
+    }
+    
+#endif
+    
+    return metadatasNet;
+}
+
 - (NSMutableArray *)verifyExistsInQueuesUploadSelector:(NSString *)selector
 {
     NSMutableArray *metadatasNet = [[NSMutableArray alloc] init];

+ 4 - 0
iOSClient/Synchronization/CCSynchronization.m

@@ -56,6 +56,10 @@
     if ([app.activeAccount length] == 0)
         return;
 
+    // verify is sync is in progress selectorDownloadSynchronized
+    if ([[app verifyExistsInQueuesDownloadSelector:selectorDownloadSynchronized] count] > 0)
+        return;
+    
     NSArray *directories = [CCCoreData getSynchronizedDirectoryActiveAccount:app.activeAccount];
     
     for (TableDirectory *directory in directories) {