Marino Faggiana 8 years ago
parent
commit
39e5300cef

+ 0 - 1
iOSClient/FileSystem/CCCoreData.h

@@ -181,7 +181,6 @@
 + (void)addTableAutomaticUpload:(CCMetadataNet *)metadataNet account:(NSString *)account context:(NSManagedObjectContext *)context;
 + (CCMetadataNet *)getTableAutomaticUploadForAccount:(NSString *)account selector:(NSString *)selector context:(NSManagedObjectContext *)context;
 + (NSUInteger)countTableAutomaticUploadForAccount:(NSString *)account selector:(NSString *)selector;
-+ (void)deleteTableAutomaticUploadForAccount:(NSString *)account fileName:(NSString *)fileName serverUrl:(NSString *)serverUrl selector:(NSString*)selector context:(NSManagedObjectContext *)context;
 
 // ===== GPS =====
 

+ 4 - 12
iOSClient/FileSystem/CCCoreData.m

@@ -1502,7 +1502,7 @@
     if (context == nil)
         context = [NSManagedObjectContext MR_context];
     
-    TableAutomaticUpload *record = [TableAutomaticUpload MR_findFirstWithPredicate:[NSPredicate predicateWithFormat:@"(account == %@) AND (selector == %@)", account, selector]];
+    TableAutomaticUpload *record = [TableAutomaticUpload MR_findFirstWithPredicate:[NSPredicate predicateWithFormat:@"(account == %@) AND (selector == %@)", account, selector] inContext:context];
     
     if (record) {
     
@@ -1518,6 +1518,9 @@
         metadataNet.session = record.session;
         metadataNet.taskStatus = taskStatusResume;                          // Default
         
+        [record MR_deleteEntityInContext:context];                          // Remove record
+        [context MR_saveToPersistentStoreAndWait];
+
         return metadataNet;
     }
     
@@ -1532,17 +1535,6 @@
         return [TableAutomaticUpload MR_countOfEntitiesWithPredicate:[NSPredicate predicateWithFormat:@"(account == %@)", account]];
 }
 
-+ (void)deleteTableAutomaticUploadForAccount:(NSString *)account fileName:(NSString *)fileName serverUrl:(NSString *)serverUrl selector:(NSString*)selector context:(NSManagedObjectContext *)context
-{
-    if (context == nil)
-        context = [NSManagedObjectContext MR_context];
-    
-    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(account == %@) AND (fileName == %@) AND (serverUrl == %@) AND (selector == %@)", account, fileName, serverUrl, selector];
-    [TableAutomaticUpload MR_deleteAllMatchingPredicate:predicate inContext:context];
-    
-    [context MR_saveToPersistentStoreAndWait];
-}
-
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ===== GPS =====
 #pragma --------------------------------------------------------------------------------------------

+ 0 - 4
iOSClient/Networking/CCNetworking.m

@@ -1358,10 +1358,6 @@
         NSLog(@"[LOG] Upload file %@ - %@ TaskIdentifier %lu", fileName,fileNamePrint, (unsigned long)uploadTask.taskIdentifier);
     }
 
-    // Automatic upload
-    if([selector isEqualToString:selectorUploadAutomatic] || [selector isEqualToString:selectorUploadAutomaticAll])
-        [CCCoreData deleteTableAutomaticUploadForAccount:_activeAccount fileName:fileNamePrint serverUrl:serverUrl selector:selector context:_context];
-            
     dispatch_async(dispatch_get_main_queue(), ^{
         
         // refresh main