Browse Source

dev table localfile

Marino Faggiana 8 years ago
parent
commit
e9db3a377b

+ 4 - 2
iOSClient/FileSystem/CCCoreData.h

@@ -131,9 +131,11 @@
 
 // ===== GeoInformation =====
 
+/*
 + (NSArray *)getGeoInformationLocalFromEtag:(NSString *)fileID activeAccount:(NSString *)activeAccount;
 + (void)setGeoInformationLocalFromEtag:(NSString *)fileID exifDate:(NSDate *)exifDate exifLatitude:(NSString *)exifLatitude exifLongitude:(NSString *)exifLongitude activeAccount:(NSString *)activeAccount;
 + (void)setGeoInformationLocalNull;
+*/
 
 // ===== Certificates =====
 
@@ -153,7 +155,7 @@
 
 //+ (void)flushTableAccount:(NSString *)account;
 //+ (void)flushTableDirectoryAccount:(NSString *)account;
-+ (void)flushTableLocalFileAccount:(NSString *)account;
+//+ (void)flushTableLocalFileAccount:(NSString *)account;
 
-+ (void)flushAllDatabase;
+//+ (void)flushAllDatabase;
 @end

+ 0 - 79
iOSClient/FileSystem/CCCoreData.m

@@ -1292,83 +1292,4 @@
     }
 }
 
-+ (void)verifyVersionCoreData:(UIViewController *)vc
-{
-    NSString *applicationName = [[[NSBundle mainBundle] infoDictionary] valueForKey:(NSString *)kCFBundleNameKey];
-    
-    // Get the path for our model (in this case it's named 'cache')
-    NSURL *url = [[NSBundle mainBundle] URLForResource:@"cryptocloud" withExtension:@"momd"];
-    NSPersistentStoreCoordinator *psc = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[[NSManagedObjectModel alloc] initWithContentsOfURL:url]]; /* get a coordinator */
-    NSString *sourceStoreType = nil;/* type for the source store, or nil if not known */ ;
-    NSString *path = [NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) firstObject];
-    // Figure out the full path where our store is located
-    path = [path stringByAppendingFormat:@"/%@/cryptocloud", applicationName];
-    NSURL *sourceStoreURL = [NSURL fileURLWithPath:path]; /* URL for the source store */ ;
-    NSError *error = nil;
-    
-    NSDictionary *sourceMetadata = [NSPersistentStoreCoordinator metadataForPersistentStoreOfType:sourceStoreType URL:sourceStoreURL error:&error];
-    
-    if (sourceMetadata == nil) {
-        
-        NSLog(@"[LOG] Error checking migration validity");
-        
-    } else {
-        
-        if (![[psc managedObjectModel] isConfiguration:nil compatibleWithStoreMetadata:sourceMetadata]) {
-            
-            UIAlertController * alert= [UIAlertController alertControllerWithTitle:nil message:NSLocalizedString(@"_required_new_database_", nil) preferredStyle:UIAlertControllerStyleAlert];
-            UIAlertAction* ok = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault
-                                                       handler:^(UIAlertAction * action) {
-                                                           [alert dismissViewControllerAnimated:YES completion:nil];
-                                                       }];
-            [alert addAction:ok];
-            [vc presentViewController:alert animated:YES completion:nil];
-            
-            // Delete CoreData store
-            NSFileManager *manager = [NSFileManager defaultManager];
-            NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
-            NSString *directory = [[paths lastObject] stringByAppendingPathComponent:applicationName];
-            NSArray *files = [manager contentsOfDirectoryAtPath:directory error:nil];
-            NSError *error;
-            
-            for(NSString *filename in files) {
-                [manager removeItemAtPath:[directory stringByAppendingPathComponent:filename] error:&error];
-            }
-        }
-    }
-}
-
-#pragma --------------------------------------------------------------------------------------------
-#pragma mark ===== Flush Database =====
-#pragma --------------------------------------------------------------------------------------------
-
-+ (void)flushTableLocalFileAccount:(NSString *)account
-{
-    NSManagedObjectContext *context = [NSManagedObjectContext MR_defaultContext];
-    
-    if (account) {
-        
-        [TableLocalFile MR_deleteAllMatchingPredicate:[NSPredicate predicateWithFormat:@"(account == %@)", account] inContext:context];
-        
-    } else {
-        
-        [TableLocalFile MR_truncateAllInContext:context];
-    }
-    
-    [context MR_saveToPersistentStoreAndWait];
-}
-
-
-
-+ (void)flushAllDatabase
-{
-    NSManagedObjectContext *context = [NSManagedObjectContext MR_defaultContext];
-    
-    [TableAccount MR_truncateAllInContext:context];
-    [TableDirectory MR_truncateAllInContext:context];
-    [TableLocalFile MR_truncateAllInContext:context];
-    
-    [context MR_saveToPersistentStoreAndWait];
-}
-
 @end

+ 2 - 5
iOSClient/Settings/CCAdvanced.m

@@ -318,11 +318,10 @@
             [[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:[tableLocalFile class] account:app.activeAccount];
             [[NCManageDatabase sharedInstance] clearTable:[tableMetadata class] account:app.activeAccount];
             [[NCManageDatabase sharedInstance] clearTable:[tableShare class] account:app.activeAccount];
             
-            [CCCoreData flushTableLocalFileAccount:app.activeAccount];
-            
             [self emptyUserDirectoryUser:app.activeUser url:app.activeUrl];
             
             [self emptyLocalDirectory];
@@ -399,9 +398,7 @@
             [[NSURLCache sharedURLCache] setDiskCapacity:0];
             
             [[CCNetworking sharedNetworking] invalidateAndCancelAllSession];
-            
-            [CCCoreData flushAllDatabase];
-            
+                        
             [[NCManageDatabase sharedInstance] removeDB];
             
             [CCUtility deleteAllChainStore];

+ 1 - 3
iOSClient/Settings/CCManageAccount.m

@@ -324,10 +324,8 @@
     [[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:[tableLocalFile class] account:app.activeAccount];
     [[NCManageDatabase sharedInstance] clearTable:[tableMetadata class] account:account];
-
-    [CCCoreData flushTableLocalFileAccount:account];
-    
     [[NCManageDatabase sharedInstance] clearTable:[tableShare class] account:account];
 }
 

+ 1 - 1
iOSClient/Utility/CCExifGeo.m

@@ -77,7 +77,7 @@
     }
     
     // Wite data EXIF in TableLocalFile
-    [CCCoreData setGeoInformationLocalFromEtag:metadata.fileID exifDate:date exifLatitude:stringLatitude exifLongitude:stringLongitude activeAccount:activeAccount];
+    [[NCManageDatabase sharedInstance] setLocalFileWithFileID:metadata.fileID date:nil exifDate:date exifLatitude:stringLatitude exifLongitude:stringLongitude fileName:nil fileNamePrint:nil];
 }
 
 + (void)setGeocoderEtag:(NSString *)fileID exifDate:(NSDate *)exifDate latitude:(NSString*)latitude longitude:(NSString*)longitude