From 78665e8cb048aed8830de266c8a788bedec1e648 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abel=20Garc=C3=ADa=20de=20Prada?= Date: Thu, 19 Jan 2023 08:19:34 +0100 Subject: [PATCH] Add support for spaces web dav specific urls to the rename operation --- .../lib/resources/files/RenameRemoteFileOperation.kt | 5 +++-- .../android/lib/resources/files/services/FileService.kt | 1 + .../files/services/implementation/OCFileService.kt | 6 ++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/RenameRemoteFileOperation.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/RenameRemoteFileOperation.kt index 8f669c69..9a0a4b30 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/RenameRemoteFileOperation.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/RenameRemoteFileOperation.kt @@ -48,6 +48,7 @@ class RenameRemoteFileOperation( private val oldRemotePath: String, private val newName: String, isFolder: Boolean, + val spaceWebDavUrl: String? = null, ) : RemoteOperation() { private var newRemotePath: String @@ -75,8 +76,8 @@ class RenameRemoteFileOperation( } val moveMethod: MoveMethod = MoveMethod( - url = URL(client.userFilesWebDavUri.toString() + WebdavUtils.encodePath(oldRemotePath)), - destinationUrl = client.userFilesWebDavUri.toString() + WebdavUtils.encodePath(newRemotePath), + url = URL((spaceWebDavUrl ?: client.userFilesWebDavUri.toString()) + WebdavUtils.encodePath(oldRemotePath)), + destinationUrl = (spaceWebDavUrl ?: client.userFilesWebDavUri.toString()) + WebdavUtils.encodePath(newRemotePath), ).apply { setReadTimeout(RENAME_READ_TIMEOUT, TimeUnit.MILLISECONDS) setConnectionTimeout(RENAME_CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS) diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/services/FileService.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/services/FileService.kt index 2fd3c0e8..89407585 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/services/FileService.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/services/FileService.kt @@ -77,5 +77,6 @@ interface FileService : Service { oldRemotePath: String, newName: String, isFolder: Boolean, + spaceWebDavUrl: String? = null, ): RemoteOperationResult } diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/services/implementation/OCFileService.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/services/implementation/OCFileService.kt index 8bbbc074..e0c6a2f6 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/services/implementation/OCFileService.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/services/implementation/OCFileService.kt @@ -123,12 +123,14 @@ class OCFileService(override val client: OwnCloudClient) : FileService { oldName: String, oldRemotePath: String, newName: String, - isFolder: Boolean + isFolder: Boolean, + spaceWebDavUrl: String?, ): RemoteOperationResult = RenameRemoteFileOperation( oldName = oldName, oldRemotePath = oldRemotePath, newName = newName, - isFolder = isFolder + isFolder = isFolder, + spaceWebDavUrl = spaceWebDavUrl, ).execute(client) }