Marino Faggiana 8 жил өмнө
parent
commit
05b588d255

+ 0 - 2
iOSClient/AppDelegate.h

@@ -76,8 +76,6 @@
 
 // Networking 
 @property (nonatomic, copy) void (^backgroundSessionCompletionHandler)(void);
-@property (nonatomic, strong) NSDate *sessionDateLastUploadTasks;
-@property (nonatomic, strong) NSDate *sessionDateLastDownloadTasks;
 
 // Network Share
 @property (nonatomic, strong) NSMutableDictionary *sharesID;

+ 3 - 31
iOSClient/AppDelegate.m

@@ -192,10 +192,6 @@
     // Initialization Notification
     self.listOfNotifications = [NSMutableArray new];
     
-    // Verify Session in progress and Init date task
-    self.sessionDateLastDownloadTasks = [NSDate date];
-    self.sessionDateLastUploadTasks = [NSDate date];
-    
     // Background Fetch
     [application setMinimumBackgroundFetchInterval:UIApplicationBackgroundFetchIntervalMinimum];
 
@@ -1380,34 +1376,16 @@
 - (void)verifyDownloadUploadInProgress
 {
     // Test Maintenance
-    if (self.maintenanceMode)
+    if (self.maintenanceMode || self.activeAccount.length == 0)
         return;
 
-    BOOL callVerifyDownload = NO;
-    BOOL callVerifyUpload = NO;
-    
     if ([[UIApplication sharedApplication] applicationState] != UIApplicationStateBackground) {
         
-        NSLog(@"[LOG] Verify Download/Upload in progress now : %@ - Download %@ - Upload %@", [NSDate date], [self.sessionDateLastDownloadTasks dateByAddingTimeInterval:k_timerVerifySession], [self.sessionDateLastUploadTasks dateByAddingTimeInterval:k_timerVerifySession]);
+        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
         
-        if ([[NSDate date] compare:[self.sessionDateLastDownloadTasks dateByAddingTimeInterval:k_timerVerifySession]] == NSOrderedDescending) {
-            
-            callVerifyDownload = YES;
             [[CCNetworking sharedNetworking] verifyDownloadInProgress];
-        }
-        
-        if ([[NSDate date] compare:[self.sessionDateLastUploadTasks dateByAddingTimeInterval:k_timerVerifySession]] == NSOrderedDescending) {
-            
-            callVerifyUpload = YES;
             [[CCNetworking sharedNetworking] verifyUploadInProgress];
-        }
-        
-        if (callVerifyDownload && callVerifyUpload) {
-            
-            NSLog(@"[LOG] Stop timer verify session");
-            
-            [self.timerVerifySessionInProgress invalidate];
-        }
+        });
     }
 }
 
@@ -1433,12 +1411,6 @@
     /*
     Task
     */
-    if ([task isKindOfClass:[NSURLSessionDownloadTask class]])
-        app.sessionDateLastDownloadTasks = [NSDate date];
-
-    if ([task isKindOfClass:[NSURLSessionUploadTask class]])
-        app.sessionDateLastUploadTasks = [NSDate date];
-    
     if (fileID && [_listChangeTask objectForKey:fileID])
         dispatch_async(dispatch_get_main_queue(), ^{
             [self changeTask:fileID];

+ 2 - 2
iOSClient/CCGlobal.h

@@ -126,8 +126,8 @@ extern NSString *const urlBaseUploadDB;
 #define k_taskStatusResume                              -2
 #define k_taskStatusSuspend                             -3
 
-#define k_timerVerifySession                            15
-#define k_timerProcess                                  7
+#define k_timerVerifySession                            5
+#define k_timerProcess                                  4
 #define k_timerUpdateApplicationIconBadgeNumber         2
 
 #define k_maxConcurrentOperation                         10

+ 6 - 12
iOSClient/Networking/CCNetworking.m

@@ -1602,12 +1602,9 @@
         }];
     }
     
-    [self automaticDownloadInError];
-}
-
-- (void)automaticDownloadInError
-{
-    NSMutableSet *serversUrl = [[NSMutableSet alloc] init];
+    /* Verify Upload In Error */
+    
+    NSMutableSet *serversUrl = [NSMutableSet new];
     
     NSArray *metadatas = [[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"account = %@ AND session CONTAINS 'download' AND (sessionTaskIdentifier = %i OR sessionTaskIdentifierPlist = %i)", _activeAccount, k_taskIdentifierError, k_taskIdentifierError] sorted:nil ascending:NO];
     
@@ -1688,12 +1685,9 @@
         [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_networkingSessionNotification object:object];
     }
     
-    [self automaticUploadInError];
-}
-
-- (void)automaticUploadInError
-{
-    NSMutableSet *directoryIDs = [[NSMutableSet alloc] init];
+    /* Verify Upload In Error */
+    
+    NSMutableSet *directoryIDs = [NSMutableSet new];
     
     NSArray *metadatas = [[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"account = %@ AND session CONTAINS 'upload' AND (sessionTaskIdentifier = %i OR sessionTaskIdentifierPlist = %i)", _activeAccount, k_taskIdentifierError, k_taskIdentifierError] sorted:nil ascending:NO];