marinofaggiana 4 years ago
parent
commit
05a55a0eb6
2 changed files with 17 additions and 0 deletions
  1. 16 0
      iOSClient/Data/NCManageDatabase.swift
  2. 1 0
      iOSClient/Settings/NCSettings.m

+ 16 - 0
iOSClient/Data/NCManageDatabase.swift

@@ -1277,6 +1277,22 @@ class NCManageDatabase: NSObject {
             setDirectory(synchronized: false, serverUrl: serverUrl, account: account)
         }
     }
+    
+    @objc func removeAllDirectoriesSynchronized(account: String) {
+        
+        let realm = try! Realm()
+        
+        do {
+            try realm.safeWrite {
+                let results = realm.objects(tableDirectory.self).filter("account == %@ AND synchronized == true", account)
+                for result in results {
+                    result.synchronized = false
+                }
+            }
+        } catch let error {
+            NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+        }
+    }
 
     //MARK: -
     //MARK: Table e2e Encryption

+ 1 - 0
iOSClient/Settings/NCSettings.m

@@ -289,6 +289,7 @@
             
             [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
                 [CCUtility setFavoriteOffline:true];
+                [[NCManageDatabase sharedInstance] removeAllDirectoriesSynchronizedWithAccount:appDelegate.account];
                 [[NCNetworking shared] listingFavoritescompletionWithSelector:(selectorDownloadAllFile) completion:^(NSString *account, NSArray *metadatas, NSInteger errorCode, NSString *errorDescription) { }];                    
             }]];