1
0
mirror of https://github.com/owncloud/android-library.git synced 2025-06-06 15:36:45 +00:00

Showing decision dialog when copying file conflict.

This commit is contained in:
Manuel Plazas Palacio 2023-05-31 17:46:06 +02:00
parent 5607f76a1d
commit d81ca97f14
3 changed files with 11 additions and 4 deletions

View File

@ -54,6 +54,7 @@ class CopyRemoteFileOperation(
private val targetRemotePath: String,
private val sourceSpaceWebDavUrl: String? = null,
private val targetSpaceWebDavUrl: String? = null,
private val forceOverride: Boolean = false,
) : RemoteOperation<String>() {
/**
@ -74,8 +75,9 @@ class CopyRemoteFileOperation(
var result: RemoteOperationResult<String>
try {
val copyMethod = CopyMethod(
URL((sourceSpaceWebDavUrl ?: client.userFilesWebDavUri.toString()) + WebdavUtils.encodePath(sourceRemotePath)),
(targetSpaceWebDavUrl ?: client.userFilesWebDavUri.toString()) + WebdavUtils.encodePath(targetRemotePath),
url = URL((sourceSpaceWebDavUrl ?: client.userFilesWebDavUri.toString()) + WebdavUtils.encodePath(sourceRemotePath)),
destinationUrl = (targetSpaceWebDavUrl ?: client.userFilesWebDavUri.toString()) + WebdavUtils.encodePath(targetRemotePath),
forceOverride = forceOverride,
).apply {
setReadTimeout(COPY_READ_TIMEOUT, TimeUnit.SECONDS)
setConnectionTimeout(COPY_CONNECTION_TIMEOUT, TimeUnit.SECONDS)
@ -87,6 +89,7 @@ class CopyRemoteFileOperation(
result = RemoteOperationResult(ResultCode.OK)
result.setData(fileRemoteId)
}
isPreconditionFailed(status) -> {
result = RemoteOperationResult(ResultCode.INVALID_OVERWRITE)
client.exhaustResponse(copyMethod.getResponseBodyAsStream())
@ -94,6 +97,7 @@ class CopyRemoteFileOperation(
/// for other errors that could be explicitly handled, check first:
/// http://www.webdav.org/specs/rfc4918.html#rfc.section.9.9.4
}
else -> {
result = RemoteOperationResult(copyMethod)
client.exhaustResponse(copyMethod.getResponseBodyAsStream())

View File

@ -39,7 +39,8 @@ interface FileService : Service {
targetRemotePath: String,
sourceSpaceWebDavUrl: String?,
targetSpaceWebDavUrl: String?,
): RemoteOperationResult<String>
replace: Boolean,
): RemoteOperationResult<String?>
fun createFolder(
remotePath: String,

View File

@ -54,12 +54,14 @@ class OCFileService(override val client: OwnCloudClient) : FileService {
targetRemotePath: String,
sourceSpaceWebDavUrl: String?,
targetSpaceWebDavUrl: String?,
): RemoteOperationResult<String> =
replace: Boolean,
): RemoteOperationResult<String?> =
CopyRemoteFileOperation(
sourceRemotePath = sourceRemotePath,
targetRemotePath = targetRemotePath,
sourceSpaceWebDavUrl = sourceSpaceWebDavUrl,
targetSpaceWebDavUrl = targetSpaceWebDavUrl,
forceOverride = replace,
).execute(client)
override fun createFolder(