Marino Faggiana 8 жил өмнө
parent
commit
65ed1b3b05

+ 0 - 14
iOSClient/AppDelegate.m

@@ -1630,20 +1630,6 @@
     
     /* ---------------------- UPGRADE VERSION ----------------------- */
     
-    if (([actualVersion compare:@"2.13" options:NSNumericSearch] == NSOrderedAscending)) {
-     
-        [CCCoreData flushTableDirectoryAccount:nil];
-        [CCCoreData flushTableLocalFileAccount:nil];
-    }
-    
-    if (([actualVersion compare:@"2.15" options:NSNumericSearch] == NSOrderedAscending)) {
-        
-        [CCCoreData setGeoInformationLocalNull];
-    }
-    
-    if (([actualVersion compare:@"2.17" options:NSNumericSearch] == NSOrderedAscending)) {
-    }
-    
     if (([actualVersion compare:@"2.17.3" options:NSNumericSearch] == NSOrderedAscending)) {
     
         // Migrate Certificates Table From CoreData to Realm

+ 1 - 1
iOSClient/FileSystem/CCCoreData.h

@@ -150,7 +150,7 @@
 + (void)moveAllUserToGroup;
 
 //+ (void)flushTableAccount:(NSString *)account;
-+ (void)flushTableDirectoryAccount:(NSString *)account;
+//+ (void)flushTableDirectoryAccount:(NSString *)account;
 + (void)flushTableLocalFileAccount:(NSString *)account;
 
 + (void)flushAllDatabase;

+ 0 - 16
iOSClient/FileSystem/CCCoreData.m

@@ -1395,22 +1395,6 @@
 #pragma mark ===== Flush Database =====
 #pragma --------------------------------------------------------------------------------------------
 
-+ (void)flushTableDirectoryAccount:(NSString *)account
-{
-    NSManagedObjectContext *context = [NSManagedObjectContext MR_defaultContext];
-    
-    if (account) {
-        
-        [TableDirectory MR_deleteAllMatchingPredicate:[NSPredicate predicateWithFormat:@"(account == %@)", account] inContext:context];
-        
-    } else {
-        
-        [TableDirectory MR_truncateAllInContext:context];
-    }
-    
-    [context MR_saveToPersistentStoreAndWait];
-}
-
 + (void)flushTableLocalFileAccount:(NSString *)account
 {
     NSManagedObjectContext *context = [NSManagedObjectContext MR_defaultContext];

+ 0 - 1
iOSClient/FileSystem/NCManageDatabase.swift

@@ -1707,7 +1707,6 @@ class NCManageDatabase: NSObject {
         }
     }
 
-
     func getDirectoryID(_ serverUrl: String) -> String {
         
         let tableAccount = self.getAccountActive()

+ 18 - 12
iOSClient/Main/CCMain.m

@@ -1921,21 +1921,27 @@
         
         return;
     }
+    
+    BOOL isDirectoryOutOfDate = true;
     tableDirectory *directory = [[NCManageDatabase sharedInstance] getTableDirectoryWithPredicate:[NSPredicate predicateWithFormat:@"serverUrl = %@", serverUrl]];
-    NSString *directoryID = directory.directoryID;
     
-    // Is Directory Out Of Date ?
-    BOOL isDirectoryOutOfDate = false;
-    NSDateComponents *dateComponents = [NSDateComponents new];
-    [dateComponents setWeekday:k_dayForceReadFolder];
-    NSCalendar *calendar = [NSCalendar currentCalendar];
+    if (directory) {
+    
+        // Is Directory Out Of Date ?
+        NSDateComponents *dateComponents = [NSDateComponents new];
+        [dateComponents setWeekday:k_dayForceReadFolder];
+        NSCalendar *calendar = [NSCalendar currentCalendar];
     
-    NSDate *datePlus = [calendar dateByAddingComponents:dateComponents toDate:directory.dateReadDirectory options:0];
-    NSDate *now = [NSDate date];
+        NSDate *datePlus = [calendar dateByAddingComponents:dateComponents toDate:directory.dateReadDirectory options:0];
+        NSDate *now = [NSDate date];
     
-    // usa la Cache se richiesto e se la data è entro X giorni dall'ultima volta che l'hai letta.
-    if ([now compare:datePlus] == NSOrderedDescending)
-        isDirectoryOutOfDate = true;
+        // usa la Cache se richiesto e se la data è entro X giorni dall'ultima volta che l'hai letta.
+        if ([now compare:datePlus] == NSOrderedDescending)
+            isDirectoryOutOfDate = true;
+        else
+            isDirectoryOutOfDate = false;
+
+    }
     
     if (isDirectoryOutOfDate || forced) {
         
@@ -1946,7 +1952,7 @@
         
         metadataNet.action = actionReadFolder;
         metadataNet.date = [NSDate date];
-        metadataNet.directoryID = directoryID;
+        metadataNet.directoryID = directory.directoryID;
         metadataNet.priority = NSOperationQueuePriorityHigh;
         metadataNet.selector = selectorReadFolder;
         metadataNet.serverUrl = serverUrl;

+ 2 - 3
iOSClient/Networking/OCNetworking.m

@@ -331,14 +331,13 @@
         //NSDate *date = [NSDate dateWithTimeIntervalSince1970:itemDtoDirectory.date];
         
         NSString *directoryID = [[NCManageDatabase sharedInstance] addDirectoryWithServerUrl:_metadataNet.serverUrl permissions:permissions];
-        
+        _metadataNet.directoryID = directoryID;
+
         NSString *cameraFolderName = [[NCManageDatabase sharedInstance] getAccountCameraUploadFolderName];
         NSString *cameraFolderPath = [[NCManageDatabase sharedInstance] getAccountCameraUploadFolderPath:_activeUrl];
         
         NSString *directoryUser = [CCUtility getDirectoryActiveUser:_activeUser activeUrl:_activeUrl];
         
-        // Update metadataNet.directoryID
-        _metadataNet.directoryID = directoryID;
         
         dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
 

+ 1 - 1
iOSClient/Settings/CCAdvanced.m

@@ -315,12 +315,12 @@
             [[NCManageDatabase sharedInstance] clearTable:[tableActivity class] account:app.activeAccount];
             [[NCManageDatabase sharedInstance] clearTable:[tableAutomaticUpload class] account:app.activeAccount];
             [[NCManageDatabase sharedInstance] clearTable:[tableCapabilities class] account:app.activeAccount];
+            [[NCManageDatabase sharedInstance] clearTable:[tableDirectory class] account:app.activeAccount];
             [[NCManageDatabase sharedInstance] clearTable:[tableExternalSites class] account:app.activeAccount];
             [[NCManageDatabase sharedInstance] clearTable:[tableGPS class] account:nil];
             [[NCManageDatabase sharedInstance] clearTable:[tableMetadata class] account:app.activeAccount];
             [[NCManageDatabase sharedInstance] clearTable:[tableShare class] account:app.activeAccount];
             
-            [CCCoreData flushTableDirectoryAccount:app.activeAccount];
             [CCCoreData flushTableLocalFileAccount:app.activeAccount];
             
             [self emptyUserDirectoryUser:app.activeUser url:app.activeUrl];

+ 1 - 1
iOSClient/Settings/CCManageAccount.m

@@ -322,10 +322,10 @@
     [[NCManageDatabase sharedInstance] clearTable:[tableActivity class] account:account];
     [[NCManageDatabase sharedInstance] clearTable:[tableAutomaticUpload class] account:account];
     [[NCManageDatabase sharedInstance] clearTable:[tableCapabilities class] account:account];
+    [[NCManageDatabase sharedInstance] clearTable:[tableDirectory class] account:app.activeAccount];
     [[NCManageDatabase sharedInstance] clearTable:[tableExternalSites class] account:account];
     [[NCManageDatabase sharedInstance] clearTable:[tableMetadata class] account:account];
 
-    [CCCoreData flushTableDirectoryAccount:account];
     [CCCoreData flushTableLocalFileAccount:account];
     
     [[NCManageDatabase sharedInstance] clearTable:[tableShare class] account:account];