Skip to content
This repository was archived by the owner on Mar 19, 2024. It is now read-only.

Commit 9c844aa

Browse files
abelgardepJuancaG05
authored andcommitted
Support removal of files from specific space
1 parent 2c18e7b commit 9c844aa

File tree

5 files changed

+14
-12
lines changed

5 files changed

+14
-12
lines changed

owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/CreateRemoteFolderOperation.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ class CreateRemoteFolderOperation(
6868
var result: RemoteOperationResult<Unit>
6969
try {
7070
val webDavUri = if (isChunksFolder) {
71-
client.uploadsWebDavUri
71+
client.uploadsWebDavUri.toString()
7272
} else {
73-
client.userFilesWebDavUri
73+
spaceWebDavUrl ?: client.userFilesWebDavUri.toString()
7474
}
7575

7676
val mkCol = MkColMethod(
77-
URL(webDavUri.toString() + WebdavUtils.encodePath(remotePath))
77+
URL(webDavUri + WebdavUtils.encodePath(remotePath))
7878
).apply {
7979
setReadTimeout(READ_TIMEOUT, TimeUnit.SECONDS)
8080
setConnectionTimeout(CONNECTION_TIMEOUT, TimeUnit.SECONDS)

owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/RemoveRemoteFileOperation.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
package com.owncloud.android.lib.resources.files
2626

27-
import android.net.Uri
2827
import com.owncloud.android.lib.common.OwnCloudClient
2928
import com.owncloud.android.lib.common.http.HttpConstants.HTTP_NO_CONTENT
3029
import com.owncloud.android.lib.common.http.HttpConstants.HTTP_OK
@@ -46,15 +45,16 @@ import java.net.URL
4645
* @author Abel García de Prada
4746
*/
4847
open class RemoveRemoteFileOperation(
49-
private val remotePath: String
48+
private val remotePath: String,
49+
val spaceWebDavUrl: String? = null,
5050
) : RemoteOperation<Unit>() {
5151

5252
override fun run(client: OwnCloudClient): RemoteOperationResult<Unit> {
5353
var result: RemoteOperationResult<Unit>
5454
try {
5555
val srcWebDavUri = getSrcWebDavUriForClient(client)
5656
val deleteMethod = DeleteMethod(
57-
URL(srcWebDavUri.toString() + WebdavUtils.encodePath(remotePath))
57+
URL(srcWebDavUri + WebdavUtils.encodePath(remotePath))
5858
)
5959
val status = client.executeHttpMethod(deleteMethod)
6060

@@ -75,7 +75,7 @@ open class RemoveRemoteFileOperation(
7575
* For standard removals, we will use [OwnCloudClient.getUserFilesWebDavUri].
7676
* In case we need a different source Uri, override this method.
7777
*/
78-
open fun getSrcWebDavUriForClient(client: OwnCloudClient): Uri = client.userFilesWebDavUri
78+
open fun getSrcWebDavUriForClient(client: OwnCloudClient): String = spaceWebDavUrl ?: client.userFilesWebDavUri.toString()
7979

8080
private fun isSuccess(status: Int) = status.isOneOf(HTTP_OK, HTTP_NO_CONTENT)
8181
}

owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/chunks/RemoveRemoteChunksFolderOperation.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@
2424
*/
2525
package com.owncloud.android.lib.resources.files.chunks
2626

27-
import android.net.Uri
2827
import com.owncloud.android.lib.common.OwnCloudClient
2928
import com.owncloud.android.lib.resources.files.RemoveRemoteFileOperation
3029

3130
class RemoveRemoteChunksFolderOperation(remotePath: String) : RemoveRemoteFileOperation(remotePath) {
32-
override fun getSrcWebDavUriForClient(client: OwnCloudClient): Uri = client.uploadsWebDavUri
31+
override fun getSrcWebDavUriForClient(client: OwnCloudClient): String = client.uploadsWebDavUri.toString()
3332
}

owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/services/FileService.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ interface FileService : Service {
6868
): RemoteOperationResult<ArrayList<RemoteFile>>
6969

7070
fun removeFile(
71-
remotePath: String
71+
remotePath: String,
72+
spaceWebDavUrl: String? = null,
7273
): RemoteOperationResult<Unit>
7374

7475
fun renameFile(

owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/services/implementation/OCFileService.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,12 @@ class OCFileService(override val client: OwnCloudClient) : FileService {
111111
).execute(client)
112112

113113
override fun removeFile(
114-
remotePath: String
114+
remotePath: String,
115+
spaceWebDavUrl: String?,
115116
): RemoteOperationResult<Unit> =
116117
RemoveRemoteFileOperation(
117-
remotePath = remotePath
118+
remotePath = remotePath,
119+
spaceWebDavUrl = spaceWebDavUrl,
118120
).execute(client)
119121

120122
override fun renameFile(

0 commit comments

Comments
 (0)