Marino Faggiana 7 years ago
parent
commit
64501ecc4b

+ 3 - 6
iOSClient/FileSystem/CCCoreData.m

@@ -1278,13 +1278,10 @@
 
 + (void)downloadFilePlist:(tableMetadata *)metadata activeAccount:(NSString *)activeAccount activeUrl:(NSString *)activeUrl directoryUser:(NSString *)directoryUser
 {
-    // inseriamo le info nel plist
-    [CCUtility insertInformationPlist:metadata directoryUser:directoryUser];
+    metadata = [[NCManageDatabase sharedInstance] copyTableMetadata:metadata];
     
-    // aggiorniamo il CCMetadata
-    //[self updateMetadata:metadata predicate:[NSPredicate predicateWithFormat:@"(fileID == %@) AND (account == %@)", metadata.fileID, activeAccount] activeAccount:activeAccount activeUrl:activeUrl context:nil];
-    
-    //[[NCManageDatabase sharedInstance] updateMetadata:metadata activeUrl:activeUrl];
+    [CCUtility insertInformationPlist:metadata directoryUser:directoryUser];    
+    [[NCManageDatabase sharedInstance] updateMetadata:metadata activeUrl:activeUrl];
     
     // se è un template aggiorniamo anche nel FileSystem
     if ([metadata.type isEqualToString: k_metadataType_template]){

+ 2 - 4
iOSClient/Main/CCMain.m

@@ -1598,11 +1598,9 @@
 
 - (void)downloadPlist:(NSString *)directoryID serverUrl:(NSString *)serverUrl
 {
-    //NSArray *records = [CCCoreData getTableMetadataWithPredicate:[NSPredicate predicateWithFormat:@"(account == %@) AND (directoryID == %@) AND ((session == NULL) OR (session == ''))", app.activeAccount, directoryID] context:nil];
+    NSArray *metadatas = [[NCManageDatabase sharedInstance] getMetadatasWithPreficate:[NSPredicate predicateWithFormat:@"account = %@ AND directoryID = %@ AND session = ''", app.activeAccount, directoryID] sorted:nil ascending:NO];
     
-    NSArray *results = [[NCManageDatabase sharedInstance] getMetadatasWithPreficate:[NSPredicate predicateWithFormat:@"(account = %@) AND (directoryID = %@) AND (session = '')", app.activeAccount, directoryID] sorted:nil ascending:NO];
-    
-    for (tableMetadata *metadata in results) {
+    for (tableMetadata *metadata in metadatas) {
             
         if ([CCUtility isCryptoPlistString:metadata.fileName] && [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"%@/%@", app.directoryUser, metadata.fileName]] == NO && [metadata.session length] == 0) {
         

+ 3 - 3
iOSClient/Networking/CCNetworking.m

@@ -1617,11 +1617,11 @@
     
     //NSArray *records = [CCCoreData getTableMetadataWithPredicate:[NSPredicate predicateWithFormat:@"(account == %@) AND (session CONTAINS 'upload') AND ((sessionTaskIdentifier == %i) OR (sessionTaskIdentifierPlist == %i))", _activeAccount, k_taskIdentifierError, k_taskIdentifierError] context:nil];
     
-    NSArray *records = [[NCManageDatabase sharedInstance] getMetadatasWithPreficate:[NSPredicate predicateWithFormat:@"(account == %@) AND (session CONTAINS 'upload') AND ((sessionTaskIdentifier == %i) OR (sessionTaskIdentifierPlist == %i))", _activeAccount, k_taskIdentifierError, k_taskIdentifierError] sorted:nil ascending:NO];
+    NSArray *metadatas = [[NCManageDatabase sharedInstance] getMetadatasWithPreficate:[NSPredicate predicateWithFormat:@"(account == %@) AND (session CONTAINS 'upload') AND ((sessionTaskIdentifier == %i) OR (sessionTaskIdentifierPlist == %i))", _activeAccount, k_taskIdentifierError, k_taskIdentifierError] sorted:nil ascending:NO];
     
-    NSLog(@"[LOG] Verify re upload n. %lu", (unsigned long)[records count]);
+    NSLog(@"[LOG] Verify re upload n. %lu", (unsigned long)[metadatas count]);
     
-    for (tableMetadata *metadata in records) {
+    for (tableMetadata *metadata in metadatas) {
                 
         [self uploadFileMetadata:metadata taskStatus: k_taskStatusResume];