Browse Source

uploading test

Marino Faggiana 6 năm trước cách đây
mục cha
commit
691d658827
1 tập tin đã thay đổi với 27 bổ sung3 xóa
  1. 27 3
      iOSClient/AppDelegate.m

+ 27 - 3
iOSClient/AppDelegate.m

@@ -1493,7 +1493,7 @@
         }
     }
     
-    // Verify Downloading
+    // Verify Transfer
     // TODO: move in new acrivity/transfers view
     //
     if (counterNewDownloadUpload == 0) {
@@ -1523,10 +1523,34 @@
                 }
             }];
         }
+        
+        NSArray *recordsInUploading = [[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND session != %@ AND status == %d", self.activeAccount, k_download_session_extension, k_metadataStatusUploading] sorted:@"fileName" ascending:true];
+        for (tableMetadata *metadata in recordsInUploading) {
+            
+            NSURLSession *session = [[CCNetworking sharedNetworking] getSessionfromSessionDescription:metadata.session];
+            
+            [session getTasksWithCompletionHandler:^(NSArray *dataTasks, NSArray *uploadTasks, NSArray *downloadTasks) {
+                
+                NSURLSessionTask *findTask;
+                
+                for (NSURLSessionTask *task in uploadTasks) {
+                    if (task.taskIdentifier == metadata.sessionTaskIdentifier) {
+                        findTask = task;
+                    }
+                }
+                
+                if (!findTask) {
+                    
+                    metadata.sessionError = @"Internal error, task not found";
+                    metadata.sessionTaskIdentifier = k_taskIdentifierDone;
+                    metadata.status = k_metadataStatusUploadError;
+                    
+                    (void)[[NCManageDatabase sharedInstance] addMetadata:metadata];
+                }
+            }];
+        }
     }
     
-//    NSArray *recordsInUpload = [[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND (status == %d OR status == %d)", self.activeAccount, k_metadataStatusInUpload, k_metadataStatusUploading] sorted:@"fileName" ascending:true];
-    
     // Start Timer
     _timerProcessAutoDownloadUpload = [NSTimer scheduledTimerWithTimeInterval:k_timerProcessAutoDownloadUpload target:self selector:@selector(processAutoDownloadUpload) userInfo:nil repeats:YES];
 }