浏览代码

Modify uploadFileFailure

Marino Faggiana 8 年之前
父节点
当前提交
69c431f125
共有 2 个文件被更改,包括 26 次插入14 次删除
  1. 15 3
      iOSClient/AppDelegate.m
  2. 11 11
      iOSClient/Main/CCMain.m

+ 15 - 3
iOSClient/AppDelegate.m

@@ -1072,11 +1072,23 @@
 
 - (void)loadTableAutomaticUploadForSelector:(NSString *)selector
 {
-    NSUInteger numRecords = 1;
-    NSArray *metadatasNet = [CCCoreData getTableAutomaticUploadForAccount:self.activeAccount selector:selector numRecords:numRecords context:nil];
+    // Verify num error if selectorUploadCameraAllPhoto
+    
+    if([selector isEqualToString:selectorUploadCameraAllPhoto]) {
+    
+        NSUInteger count = [TableAutomaticUpload MR_countOfEntitiesWithPredicate:[NSPredicate predicateWithFormat:@"(account == %@) AND (sessionSelector == %@) AND ((sessionTaskIdentifier == %i) OR (sessionTaskIdentifierPlist == %i))", app.activeAccount, selectorUploadCameraAllPhoto,taskIdentifierError, taskIdentifierError]];
+        
+        if (count >= 10) {
+            [app messageNotification:@"Troppi errori, invio sospeso" description:@"" visible:YES delay:dismissAfterSecond type:TWMessageBarMessageTypeError];
+        }
+        
+        return;
+    }
     
     // Add Network queue
-
+    
+    NSArray *metadatasNet = [CCCoreData getTableAutomaticUploadForAccount:self.activeAccount selector:selector numRecords:1 context:nil];
+    
     for (CCMetadataNet *metadataNet in metadatasNet) {
         
         NSOperationQueue *queue;

+ 11 - 11
iOSClient/Main/CCMain.m

@@ -1378,27 +1378,27 @@
 
 - (void)uploadFileFailure:(NSString *)fileID serverUrl:(NSString *)serverUrl selector:(NSString *)selector message:(NSString *)message errorCode:(NSInteger)errorCode
 {
+    CCMetadata *metadata = [CCCoreData getMetadataWithPreficate:[NSPredicate predicateWithFormat:@"(fileID == %@) AND (account == %@)", fileID, app.activeAccount] context:nil];
+    
+    // Read File test do not exists
     if (errorCode == CCErrorFileUploadNotFound) {
        
         // reUpload
-        CCMetadata *metadata = [CCCoreData getMetadataWithPreficate:[NSPredicate predicateWithFormat:@"(fileID == %@) AND (account == %@)", fileID, app.activeAccount] context:nil];
         if (metadata)
             [[CCNetworking sharedNetworking] uploadFileMetadata:metadata taskStatus:taskStatusResume];
     }
+    
+    // Print error
     else if (errorCode != kCFURLErrorCancelled && errorCode != 403) {
         
         [app messageNotification:@"_upload_file_" description:message visible:YES delay:dismissAfterSecond type:TWMessageBarMessageTypeError];
+    }
+    
+    // Automatic upload
+    if([selector isEqualToString:selectorUploadCameraSnapshot] || [selector isEqualToString:selectorUploadCameraAllPhoto]) {
         
-        // Check errors for selectorUploadCameraAllPhoto
-        if ([selector isEqualToString:selectorUploadCameraAllPhoto]) {
-            
-            NSArray *records = [CCCoreData getTableMetadataWithPredicate:[NSPredicate predicateWithFormat:@"(account == %@) AND (sessionSelector == %@) AND ((sessionTaskIdentifier == %i) OR (sessionTaskIdentifierPlist == %i))", app.activeAccount, selectorUploadCameraAllPhoto,taskIdentifierError, taskIdentifierError] context:nil];
-            
-            // fatal error(s)
-            if ([records count] >= 10 || errorCode == NSURLErrorNotConnectedToInternet) {
-                //[app dropCameraUploadAllPhoto];
-            }
-        }
+        [CCCoreData deleteTableAutomaticUploadFromAccount:app.activeAccount fileName:metadata.fileNamePrint serverUrl:serverUrl selector:selector context:nil];
+        [app loadTableAutomaticUploadForSelector:selector];
     }
     
     [self getDataSourceWithReloadTableView:[CCCoreData getDirectoryIDFromServerUrl:serverUrl activeAccount:app.activeAccount] fileID:nil selector:selector];