marinofaggiana 5 years ago
parent
commit
fa2f9038d1
1 changed files with 7 additions and 2 deletions
  1. 7 2
      iOSClient/Database/NCManageDatabase.swift

+ 7 - 2
iOSClient/Database/NCManageDatabase.swift

@@ -1064,9 +1064,14 @@ class NCManageDatabase: NSObject {
         let realm = try! Realm()
         realm.beginWrite()
         
-        let addObject = tableDirectory()
+        var addObject = tableDirectory()
         
-        addObject.ocId = ocId
+        let result = realm.objects(tableDirectory.self).filter("ocId == %@", ocId).first
+        if result != nil {
+            addObject = result!
+        } else {
+            addObject.ocId = ocId
+        }
         addObject.account = account
         addObject.e2eEncrypted = encrypted
         addObject.favorite = favorite