Marino Faggiana 8 жил өмнө
parent
commit
338881dbbf

+ 1 - 2
iOSClient/Actions/CCActions.swift

@@ -425,8 +425,7 @@ class CCActions: NSObject {
         
         metadataNet.action = actionListingFavorites
         metadataNet.delegate = delegate
-        metadataNet.priority = Operation.QueuePriority.normal.rawValue
-        //metadataNet.selector = selectorAddFavorite
+        metadataNet.priority = Operation.QueuePriority.veryHigh.rawValue
         metadataNet.serverUrl = serverUrl
         
         appDelegate.addNetworkingOperationQueue(appDelegate.netQueue, delegate: self, metadataNet: metadataNet)

+ 5 - 6
iOSClient/AppDelegate.m

@@ -341,10 +341,12 @@
 {
     // now
     dispatch_async(dispatch_get_main_queue(), ^{
-        
+       
+        NSLog(@"[LOG] Listning Favorites");
+        [[CCSynchronize sharedSynchronize] readListingFavorites];
     });
 
-    // 0.5 sec.
+    // after 0.5 sec.
     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
         
         NSLog(@"[LOG] Request Server Information");
@@ -355,9 +357,6 @@
         NSLog(@"[LOG] Initialize Camera Upload");
         [[NSNotificationCenter defaultCenter] postNotificationName:@"initStateCameraUpload" object:nil];
         
-        NSLog(@"[LOG] Listning Favorites");
-        [[CCSynchronize sharedSynchronize] readListingFavorites];
-        
         NSLog(@"[LOG] files Offline");
         [[CCSynchronize sharedSynchronize] readOffline];
     });
@@ -1081,7 +1080,7 @@
     id operation;
     
     operation = [[OCnetworking alloc] initWithDelegate:delegate metadataNet:metadataNet withUser:_activeUser withPassword:_activePassword withUrl:_activeUrl isCryptoCloudMode:_isCryptoCloudMode];
-    
+        
     [operation setQueuePriority:metadataNet.priority];
     
     [netQueue addOperation:operation];

+ 17 - 22
iOSClient/Offline/CCSynchronize.m

@@ -95,38 +95,26 @@
         return;
     
     NSString *father = @"";
+    NSMutableArray *filesID = [NSMutableArray new];
     
     for (CCMetadata *metadata in metadatas) {
         
-        // Delete Record NOT in session
-        [CCCoreData deleteMetadataWithPredicate:[NSPredicate predicateWithFormat:@"(account == %@) AND (directoryID == %@) AND (fileID = %@) AND ((session == NULL) OR (session == ''))", app.activeAccount, metadata.directoryID, metadata.fileID]];
-        
         // type of file
         NSInteger typeFilename = [CCUtility getTypeFileName:metadata.fileName];
         
-        // if crypto do not insert
-        if (typeFilename == k_metadataTypeFilenameCrypto) continue;
-        
-        // verify if the record encrypted has plist + crypto
-        if (typeFilename == k_metadataTypeFilenamePlist && metadata.directory == NO) {
-            
-            BOOL isCryptoComplete = NO;
-            NSString *fileNameCrypto = [CCUtility trasformedFileNamePlistInCrypto:metadata.fileName];
-            
-            for (CCMetadata *completeMetadata in metadatas) {
-                
-                if (completeMetadata.cryptated == NO) continue;
-                else  if ([completeMetadata.fileName isEqualToString:fileNameCrypto]) {
-                    isCryptoComplete = YES;
-                    break;
-                }
-            }
-            if (isCryptoComplete == NO) continue;
-        }
+        // do not insert cryptated favorite file
+        if (typeFilename == k_metadataTypeFilenameCrypto || typeFilename == k_metadataTypeFilenamePlist)
+            continue;
+
+        // Delete Record NOT in session
+        [CCCoreData deleteMetadataWithPredicate:[NSPredicate predicateWithFormat:@"(account == %@) AND (directoryID == %@) AND (fileID = %@) AND ((session == NULL) OR (session == ''))", app.activeAccount, metadata.directoryID, metadata.fileID]];
         
         // end test, insert in CoreData
         [CCCoreData addMetadata:metadata activeAccount:app.activeAccount activeUrl:app.activeUrl context:nil];
         
+        // insert for test NOT favorite
+        [filesID addObject:metadata.fileID];
+        
         // ---- Synchronized ----
         
         // Get ServerUrl
@@ -149,6 +137,13 @@
         }
     }
     
+    // Verify remove favorite
+    NSArray *allRecordFavorite = [CCCoreData getTableMetadataWithPredicate:[NSPredicate predicateWithFormat:@"(account == %@) AND (favorite == 1)", app.activeAccount] context:nil];
+    
+    for (TableMetadata *tableMetadata in allRecordFavorite)
+        if (![filesID containsObject:tableMetadata.fileID])
+            [CCCoreData SetMetadataFavoriteFileID:tableMetadata.fileID favorite:NO activeAccount:app.activeAccount context:nil];
+    
     [[NSNotificationCenter defaultCenter] postNotificationName:@"clearDateReadDataSource" object:nil];
 }