Jelajahi Sumber

Improved : selectorUploadAutomaticAll

Marino Faggiana 8 tahun lalu
induk
melakukan
2f7d9304e2
2 mengubah file dengan 18 tambahan dan 3 penghapusan
  1. 1 0
      iOSClient/AppDelegate.h
  2. 17 3
      iOSClient/AppDelegate.m

+ 1 - 0
iOSClient/AppDelegate.h

@@ -92,6 +92,7 @@
 
 
 // Check new Asset Photos/Video in progress 
 // Check new Asset Photos/Video in progress 
 @property BOOL automaticCheckAssetInProgress;
 @property BOOL automaticCheckAssetInProgress;
+@property BOOL automaticUploadInProgress;
 
 
 // UploadFromOtherUpp
 // UploadFromOtherUpp
 @property (nonatomic, strong) NSString *fileNameUpload;
 @property (nonatomic, strong) NSString *fileNameUpload;

+ 17 - 3
iOSClient/AppDelegate.m

@@ -175,6 +175,7 @@
     
     
     // Check new Asset Photos/Video in progress  
     // Check new Asset Photos/Video in progress  
     _automaticCheckAssetInProgress = NO;
     _automaticCheckAssetInProgress = NO;
+    _automaticUploadInProgress = NO;
     
     
     // Add notification change session
     // Add notification change session
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sessionChanged:) name:k_networkingSessionNotification object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sessionChanged:) name:k_networkingSessionNotification object:nil];
@@ -1214,10 +1215,13 @@
 {
 {
     CCMetadataNet *metadataNet;
     CCMetadataNet *metadataNet;
     
     
-    // Is loading new Asset ?
-    if (_automaticCheckAssetInProgress)
+    // Is loading new Asset or this  ?
+    if (_automaticCheckAssetInProgress || _automaticUploadInProgress)
         return;
         return;
     
     
+    // START Automatic Upload in progress
+    _automaticUploadInProgress = YES;
+    
     NSArray *uploadInQueue = [CCCoreData getTableMetadataUploadAccount:app.activeAccount];
     NSArray *uploadInQueue = [CCCoreData getTableMetadataUploadAccount:app.activeAccount];
     NSArray *recordAutomaticUploadInLock = [CCCoreData getAllLockTableAutomaticUploadForAccount:_activeAccount];
     NSArray *recordAutomaticUploadInLock = [CCCoreData getAllLockTableAutomaticUploadForAccount:_activeAccount];
     
     
@@ -1267,13 +1271,21 @@
         
         
         [app messageNotification:@"_error_" description:@"_too_errors_automatic_all_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError];
         [app messageNotification:@"_error_" description:@"_too_errors_automatic_all_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError];
         
         
+        // STOP Im progress
+        _automaticUploadInProgress = NO;
+        
         return;
         return;
     }
     }
     
     
     NSUInteger count = [TableMetadata MR_countOfEntitiesWithPredicate:[NSPredicate predicateWithFormat:@"(account == %@) AND (sessionSelector == %@) AND ((sessionTaskIdentifier > 0) OR (sessionTaskIdentifierPlist > 0))", app.activeAccount, selectorUploadAutomaticAll]];
     NSUInteger count = [TableMetadata MR_countOfEntitiesWithPredicate:[NSPredicate predicateWithFormat:@"(account == %@) AND (sessionSelector == %@) AND ((sessionTaskIdentifier > 0) OR (sessionTaskIdentifierPlist > 0))", app.activeAccount, selectorUploadAutomaticAll]];
     
     
-    if (count >= k_maxConcurrentOperationDownloadUpload)
+    if (count >= k_maxConcurrentOperationDownloadUpload) {
+        
+        // STOP Im progress
+        _automaticUploadInProgress = NO;
+        
         return;
         return;
+    }
     
     
     metadataNet = [CCCoreData getTableAutomaticUploadForAccount:self.activeAccount selector:selectorUploadAutomaticAll];
     metadataNet = [CCCoreData getTableAutomaticUploadForAccount:self.activeAccount selector:selectorUploadAutomaticAll];
     if (metadataNet) {
     if (metadataNet) {
@@ -1294,6 +1306,8 @@
         }
         }
     }
     }
     
     
+    // STOP Im progress
+    _automaticUploadInProgress = NO;
 }
 }
 
 
 - (void)verifyDownloadUploadInProgress
 - (void)verifyDownloadUploadInProgress