Browse Source

Adjustment disable/removed automatic upload

Marino Faggiana 8 years ago
parent
commit
7daca0a5e6

+ 1 - 1
iOSClient/AppDelegate.h

@@ -185,7 +185,7 @@
 - (void)loadTableAutomaticUploadForSelector:(NSString *)selector numeRecors:(NSUInteger)numRecords;
 - (BOOL)verifyExistsFileName:(NSString *)fileName withSelector:(NSString *)selector inOperationsQueue:(NSOperationQueue *)queue;
 
-- (void)dropCameraUploadAllPhoto;
+- (void)dropAutomaticUploadWithSelector:(NSString *)selector;
 
 @end
 

+ 6 - 9
iOSClient/AppDelegate.m

@@ -308,9 +308,7 @@
 // L'applicazione terminerà
 //
 - (void)applicationWillTerminate:(UIApplication *)application
-{
-    [self dropCameraUploadAllPhoto];
-    
+{    
     [MagicalRecord cleanUp];
 
     NSLog(@"[LOG] bye bye, Crypto Cloud !");
@@ -1241,16 +1239,15 @@
         [_activeMain getDataSourceWithReloadTableView:metadata.directoryID fileID:nil selector:nil];
 }
 
-- (void)dropCameraUploadAllPhoto
+- (void)dropAutomaticUploadWithSelector:(NSString *)selector
 {
-    [_netQueueUploadCamera cancelAllOperations];
-    
-    [CCCoreData deleteMetadataWithPredicate:[NSPredicate predicateWithFormat:@"(account == %@) AND (session != NULL) AND (session != '') AND ((sessionSelector == %@))", self.activeAccount, selectorUploadCameraAllPhoto]];
+    //[_netQueueUploadCamera cancelAllOperations];
     
-    [CCCoreData setCameraUploadFullPhotosActiveAccount:NO activeAccount:app.activeAccount];
+    [CCCoreData flushTableAutomaticUploadAccount:self.activeAccount selector:selector];
+    //[CCCoreData deleteMetadataWithPredicate:[NSPredicate predicateWithFormat:@"(account == %@) AND (session != NULL) AND (session != '') AND ((sessionSelector == %@))", self.activeAccount, selector]];
     
     // Update icon badge number
-    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 3.0 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
+    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1.0 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
         [self updateApplicationIconBadgeNumber];
     });
 }

+ 1 - 0
iOSClient/FileSystem/CCCoreData.h

@@ -212,6 +212,7 @@
 
 //+ (void)verifyVersionCoreData;
 
++ (void)flushTableAutomaticUploadAccount:(NSString *)account selector:(NSString *)selector;
 + (void)flushTableDirectoryAccount:(NSString *)account;
 + (void)flushTableLocalFileAccount:(NSString *)account;
 + (void)flushTableMetadataAccount:(NSString *)account;

+ 17 - 3
iOSClient/FileSystem/CCCoreData.m

@@ -1480,7 +1480,6 @@
     if (context == nil)
         context = [NSManagedObjectContext MR_context];
     
-    
     NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(account == %@) AND (fileName == %@) AND (serverUrl == %@)", activeAccount, metadataNet.fileName, metadataNet.serverUrl];
     record = [TableAutomaticUpload MR_findFirstWithPredicate:predicate inContext:context];
     
@@ -1497,6 +1496,7 @@
         record.serverUrl = metadataNet.serverUrl;
         record.session = metadataNet.session;
         record.priority = [NSNumber numberWithLong:metadataNet.priority];
+        record.startUpload = [NSNumber numberWithBool:NO];
         
         [context MR_saveToPersistentStoreAndWait];
     }
@@ -1513,7 +1513,7 @@
     if (context == nil)
         context = [NSManagedObjectContext MR_context];
     
-    NSPredicate *peopleFilter = [NSPredicate predicateWithFormat:@"(account == %@) AND (selector == %@) AND (startUpload == 0)", activeAccount, selector, taskIdentifierDone];
+    NSPredicate *peopleFilter = [NSPredicate predicateWithFormat:@"(account == %@) AND (selector == %@) AND (startUpload == 0)", activeAccount, selector];
     NSArray *records = [TableAutomaticUpload MR_findAllWithPredicate:peopleFilter];
     
     for (TableAutomaticUpload *record in records) {
@@ -2024,6 +2024,20 @@
     }
 }
 
++ (void)flushTableAutomaticUploadAccount:(NSString *)account selector:(NSString *)selector
+{
+    NSManagedObjectContext *context = [NSManagedObjectContext MR_defaultContext];
+    
+    if (account && selector)
+        [TableAutomaticUpload MR_deleteAllMatchingPredicate:[NSPredicate predicateWithFormat:@"(account == %@) AND (selector == %@)", account, selector] inContext:context];
+    else if (account && !selector )
+        [TableAutomaticUpload MR_deleteAllMatchingPredicate:[NSPredicate predicateWithFormat:@"(account == %@)", account] inContext:context];
+    else
+        [TableAutomaticUpload MR_truncateAllInContext:context];
+    
+    [context MR_saveToPersistentStoreAndWait];
+}
+
 + (void)flushTableDirectoryAccount:(NSString *)account
 {
     NSManagedObjectContext *context = [NSManagedObjectContext MR_defaultContext];
@@ -2086,7 +2100,7 @@
     NSManagedObjectContext *context = [NSManagedObjectContext MR_defaultContext];
     
     [TableAccount MR_truncateAllInContext:context];
-    
+    [TableAutomaticUpload MR_truncateAllInContext:context];
     [TableCertificates MR_truncateAllInContext:context];
     [TableDirectory MR_truncateAllInContext:context];
     [TableGPS MR_truncateAllInContext:context];

+ 3 - 2
iOSClient/Main/CCMain.m

@@ -1395,8 +1395,9 @@
             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];
+            if ([records count] >= 10 || errorCode == NSURLErrorNotConnectedToInternet) {
+                //[app dropCameraUploadAllPhoto];
+            }
         }
     }
     

+ 2 - 10
iOSClient/PhotosCameraUpload/CCPhotosCameraUpload.m

@@ -1116,12 +1116,8 @@
     if(![self createFolder:folderPathName]) {
         
         // Full Upload ?
-        if (assetsFull) {
-                
+        if (assetsFull)
             [app messageNotification:@"_error_" description:NSLocalizedStringFromTable(@"_not_possible_create_folder_", @"Error", nil) visible:YES delay:dismissAfterSecond type:TWMessageBarMessageTypeInfo];
-                
-            [app dropCameraUploadAllPhoto];
-        }
         
         // START new request : initStateCameraUpload
         _AutomaticCameraUploadInProgress = NO;
@@ -1198,12 +1194,8 @@
                 
                 [self endLoadingAssets];
                 
-                if (assetsFull) {
-                    
+                if (assetsFull)
                     [app messageNotification:@"_error_" description:@"_error_createsubfolders_upload_" visible:YES delay:dismissAfterSecond type:TWMessageBarMessageTypeInfo];
-                    
-                    [app dropCameraUploadAllPhoto];
-                }
                 
                 return;
             }

+ 6 - 4
iOSClient/Settings/CCManageCameraUpload.m

@@ -232,9 +232,10 @@
             
             [CCCoreData setCameraUploadDatePhoto:NULL];
             [CCCoreData setCameraUploadDateVideo:NULL];
-            
-            // remove queue upload
-            [[CCNetworking sharedNetworking] settingSessionsDownload:NO upload:YES taskStatus:taskStatusCancel activeAccount:app.activeAccount activeUser:app.activeUser activeUrl:app.activeUrl];
+
+            // remove
+            [app dropAutomaticUploadWithSelector:selectorUploadCameraSnapshot];
+            [app dropAutomaticUploadWithSelector:selectorUploadCameraAllPhoto];
         }
         
         // Initialize Camera Upload
@@ -281,7 +282,8 @@
             
         } else {
             
-            [app dropCameraUploadAllPhoto];
+            [app dropAutomaticUploadWithSelector:selectorUploadCameraAllPhoto];
+            [CCCoreData setCameraUploadFullPhotosActiveAccount:NO activeAccount:app.activeAccount];
         }
     }
 

+ 1 - 1
iOSClient/cryptocloud.xcdatamodeld/cryptocloud 5.xcdatamodel/contents

@@ -37,7 +37,7 @@
         <attribute name="selectorPost" optional="YES" attributeType="String" syncable="YES"/>
         <attribute name="serverUrl" optional="YES" attributeType="String" syncable="YES"/>
         <attribute name="session" optional="YES" attributeType="String" syncable="YES"/>
-        <attribute name="startUpload" optional="YES" attributeType="Boolean" defaultValueString="-1" usesScalarValueType="NO" syncable="YES"/>
+        <attribute name="startUpload" optional="YES" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="NO" syncable="YES"/>
     </entity>
     <entity name="TableCertificates" representedClassName="TableCertificates" syncable="YES">
         <attribute name="certificateLocation" optional="YES" attributeType="String" syncable="YES"/>