瀏覽代碼

Fix parent path for keep_both decision

Signed-off-by: alperozturk <alper_ozturk@proton.me>
alperozturk 10 月之前
父節點
當前提交
efaaaba93a

+ 0 - 31
app/src/androidTest/java/com/nextcloud/extensions/OfflineOperationExtensionTests.kt

@@ -19,37 +19,6 @@ import org.junit.runner.RunWith
 
 
 @RunWith(AndroidJUnit4::class)
 @RunWith(AndroidJUnit4::class)
 class OfflineOperationExtensionTests {
 class OfflineOperationExtensionTests {
-
-    /*
-      private val entity = OfflineOperationEntity(
-        1,
-        null,
-        null,
-        OfflineOperationType.CreateFolder,
-        "/Folder/Folder2/Folder3/",
-        "Folder",
-        null
-    )
-
-    @Test
-    fun testGetParentPathFromPath() {
-        assert(entity.getParentPathFromPath() == "/Folder/")
-    }
-
-    @Test
-    fun testUpdatePath() {
-        assert(entity.updatePath("/MaxPa/") == "/MaxPa/Folder2/Folder3/")
-    }
-
-    @Test
-    fun testUpdatePathsIfParentPathMatches() {
-        entity.path = "/MaxPa/Folder2/Folder3/"
-        val oldPath = "/Folder/Folder2/Folder3/"
-        assert(entity.updatePathsIfParentPathMatches(oldPath, "/MaxPa/") == "/MaxPa/Folder2/Folder3/")
-    }
-
-     */
-
     @Test
     @Test
     fun testUpdatePathsIfParentPathMatches() {
     fun testUpdatePathsIfParentPathMatches() {
         val entity1 = OfflineOperationEntity(path = "/abc/def/file1/")
         val entity1 = OfflineOperationEntity(path = "/abc/def/file1/")

+ 2 - 3
app/src/main/java/com/nextcloud/utils/extensions/OfflineOperationExtensions.kt

@@ -10,14 +10,13 @@ package com.nextcloud.utils.extensions
 import com.nextcloud.client.database.dao.OfflineOperationDao
 import com.nextcloud.client.database.dao.OfflineOperationDao
 import com.nextcloud.client.database.entity.OfflineOperationEntity
 import com.nextcloud.client.database.entity.OfflineOperationEntity
 
 
-fun OfflineOperationDao.updatePathsIfParentPathMatches(oldPath: String?, newTopDir: String?) {
+fun OfflineOperationDao.updatePathsIfParentPathMatches(oldPath: String?, newTopDir: String?, parentPath: String?) {
     if (oldPath.isNullOrEmpty() || newTopDir.isNullOrEmpty()) return
     if (oldPath.isNullOrEmpty() || newTopDir.isNullOrEmpty()) return
 
 
     getAll().forEach {
     getAll().forEach {
         val newPath = it.updatePathsIfParentPathMatches(oldPath, newTopDir)
         val newPath = it.updatePathsIfParentPathMatches(oldPath, newTopDir)
         if (newPath != it.path) {
         if (newPath != it.path) {
-
-            // TODO add parent path so it can upload
+            it.parentPath = parentPath
             it.path = newPath
             it.path = newPath
             update(it)
             update(it)
         }
         }