Ver Fonte

Improved directory, cache, remove account

marinofaggiana há 5 anos atrás
pai
commit
430e61a4d0

+ 7 - 2
iOSClient/AppDelegate.m

@@ -396,8 +396,13 @@ PKPushRegistry *pushRegistry;
     [self unsubscribingNextcloudServerPushNotification:account url:self.activeUrl withSubscribing:false];
     [self settingActiveAccount:nil activeUrl:nil activeUser:nil activeUserID:nil activePassword:nil];
     
-    [[NCUtility sharedInstance] clearDBAccount:account removeUser:true];
-    
+    [[NCManageDatabase sharedInstance] clearDatabaseWithAccount:account removeUser:true];
+
+    [CCUtility clearAllKeysEndToEnd:account];
+    [CCUtility clearAllKeysPushNotification:account];
+    [CCUtility setCertificateError:account error:false];
+    [CCUtility setPassword:account password:nil];
+       
     if (withChangeUser) {
         NSArray *listAccount = [[NCManageDatabase sharedInstance] getAccounts];
         if ([listAccount count] > 0) {

+ 34 - 7
iOSClient/Settings/CCAdvanced.m

@@ -206,14 +206,28 @@
     
     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.3 * NSEC_PER_SEC),dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
         
-        [[NCUtility sharedInstance] clearDBAccount:appDelegate.activeAccount removeUser:false];
-        [[NCUtility sharedInstance] removeAllSettingsWithRemoveKeychain:false removeApplicationSupport:false];
-        [[NCAutoUpload sharedInstance] alignPhotoLibrary];
-        [appDelegate.filterFileID removeAllObjects];
+        [[CCNetworking sharedNetworking] invalidateAndCancelAllSession];
+        [[NSURLCache sharedURLCache] setMemoryCapacity:0];
+        [[NSURLCache sharedURLCache] setDiskCapacity:0];
+        [KTVHTTPCache cacheDeleteAllCaches];
+        
+        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
+
+            [[NCManageDatabase sharedInstance] clearDatabaseWithAccount:appDelegate.activeAccount removeUser:false];
+            
+            [CCUtility emptyGroupDirectoryProviderStorage];
+            [CCUtility emptyGroupLibraryDirectory];
+            [CCUtility emptyGroupCaches];
+            [CCUtility emptyDocumentsDirectory];
+            [CCUtility emptyTemporaryDirectory];
+            [CCUtility emptyLibraryDirectory];
+            [CCUtility createDirectoryStandard];
+
+            [[NCAutoUpload sharedInstance] alignPhotoLibrary];
+            [appDelegate.filterFileID removeAllObjects];
 
-        [appDelegate maintenanceMode:NO];
+            [appDelegate maintenanceMode:NO];
         
-        dispatch_async(dispatch_get_main_queue(), ^{
             // Close HUD
             [self.hud hideHud];
             // Inizialized home
@@ -261,8 +275,21 @@
         
         dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.3 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
             
+            [[CCNetworking sharedNetworking] invalidateAndCancelAllSession];
+            [[NSURLCache sharedURLCache] setMemoryCapacity:0];
+            [[NSURLCache sharedURLCache] setDiskCapacity:0];
+            [KTVHTTPCache cacheDeleteAllCaches];
+
             [[NCManageDatabase sharedInstance] removeDB];
-            [NCUtility.sharedInstance removeAllSettingsWithRemoveKeychain:true removeApplicationSupport:true];
+            
+            [CCUtility emptyGroupDirectoryProviderStorage];
+            [CCUtility emptyGroupApplicationSupport];
+            [CCUtility emptyGroupCaches];
+            [CCUtility emptyDocumentsDirectory];
+            [CCUtility emptyTemporaryDirectory];
+            [CCUtility emptyLibraryDirectory];
+            
+            [CCUtility deleteAllChainStore];
             
             [self.hud hideHud];
             

+ 0 - 38
iOSClient/Utility/NCUtility.swift

@@ -374,43 +374,5 @@ class NCUtility: NSObject {
         
         return false
     }
-    
-    @objc func clearDBAccount(_ account: String?, removeUser: Bool) {
-        
-        NCManageDatabase.sharedInstance.clearDatabase(account: account, removeUser: removeUser)
-        
-        if (account != nil && removeUser) {            
-            CCUtility.clearAllKeysEnd(toEnd: account)
-            CCUtility.clearAllKeysPushNotification(account)
-            CCUtility.setCertificateError(account, error: false)
-            CCUtility.setPassword(account, password: nil)
-        }
-    }
-    
-    @objc func removeAllSettings(removeKeychain: Bool, removeApplicationSupport: Bool) {
-        
-        URLCache.shared.memoryCapacity = 0
-        URLCache.shared.diskCapacity = 0
-        CCNetworking.shared()?.invalidateAndCancelAllSession()
-        KTVHTTPCache.cacheDeleteAllCaches()
-        
-        CCUtility.emptyGroupDirectoryProviderStorage()
-        if removeApplicationSupport {
-            CCUtility.emptyGroupApplicationSupport()
-        } else {
-            CCUtility.emptyGroupLibraryDirectory()
-        }
-        CCUtility.emptyGroupCaches()
-        
-        CCUtility.emptyDocumentsDirectory()
-        CCUtility.emptyTemporaryDirectory()
-        CCUtility.emptyLibraryDirectory()
-        
-        CCUtility.createDirectoryStandard()
-        
-        if removeKeychain {
-            CCUtility.deleteAllChainStore()
-        }
-    }
 }