mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-07 07:56:19 +00:00
Showing decision dialog when copying file conflict.
This commit is contained in:
parent
5607f76a1d
commit
d81ca97f14
@ -54,6 +54,7 @@ class CopyRemoteFileOperation(
|
|||||||
private val targetRemotePath: String,
|
private val targetRemotePath: String,
|
||||||
private val sourceSpaceWebDavUrl: String? = null,
|
private val sourceSpaceWebDavUrl: String? = null,
|
||||||
private val targetSpaceWebDavUrl: String? = null,
|
private val targetSpaceWebDavUrl: String? = null,
|
||||||
|
private val forceOverride: Boolean = false,
|
||||||
) : RemoteOperation<String>() {
|
) : RemoteOperation<String>() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -74,8 +75,9 @@ class CopyRemoteFileOperation(
|
|||||||
var result: RemoteOperationResult<String>
|
var result: RemoteOperationResult<String>
|
||||||
try {
|
try {
|
||||||
val copyMethod = CopyMethod(
|
val copyMethod = CopyMethod(
|
||||||
URL((sourceSpaceWebDavUrl ?: client.userFilesWebDavUri.toString()) + WebdavUtils.encodePath(sourceRemotePath)),
|
url = URL((sourceSpaceWebDavUrl ?: client.userFilesWebDavUri.toString()) + WebdavUtils.encodePath(sourceRemotePath)),
|
||||||
(targetSpaceWebDavUrl ?: client.userFilesWebDavUri.toString()) + WebdavUtils.encodePath(targetRemotePath),
|
destinationUrl = (targetSpaceWebDavUrl ?: client.userFilesWebDavUri.toString()) + WebdavUtils.encodePath(targetRemotePath),
|
||||||
|
forceOverride = forceOverride,
|
||||||
).apply {
|
).apply {
|
||||||
setReadTimeout(COPY_READ_TIMEOUT, TimeUnit.SECONDS)
|
setReadTimeout(COPY_READ_TIMEOUT, TimeUnit.SECONDS)
|
||||||
setConnectionTimeout(COPY_CONNECTION_TIMEOUT, TimeUnit.SECONDS)
|
setConnectionTimeout(COPY_CONNECTION_TIMEOUT, TimeUnit.SECONDS)
|
||||||
@ -87,6 +89,7 @@ class CopyRemoteFileOperation(
|
|||||||
result = RemoteOperationResult(ResultCode.OK)
|
result = RemoteOperationResult(ResultCode.OK)
|
||||||
result.setData(fileRemoteId)
|
result.setData(fileRemoteId)
|
||||||
}
|
}
|
||||||
|
|
||||||
isPreconditionFailed(status) -> {
|
isPreconditionFailed(status) -> {
|
||||||
result = RemoteOperationResult(ResultCode.INVALID_OVERWRITE)
|
result = RemoteOperationResult(ResultCode.INVALID_OVERWRITE)
|
||||||
client.exhaustResponse(copyMethod.getResponseBodyAsStream())
|
client.exhaustResponse(copyMethod.getResponseBodyAsStream())
|
||||||
@ -94,6 +97,7 @@ class CopyRemoteFileOperation(
|
|||||||
/// for other errors that could be explicitly handled, check first:
|
/// for other errors that could be explicitly handled, check first:
|
||||||
/// http://www.webdav.org/specs/rfc4918.html#rfc.section.9.9.4
|
/// http://www.webdav.org/specs/rfc4918.html#rfc.section.9.9.4
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
result = RemoteOperationResult(copyMethod)
|
result = RemoteOperationResult(copyMethod)
|
||||||
client.exhaustResponse(copyMethod.getResponseBodyAsStream())
|
client.exhaustResponse(copyMethod.getResponseBodyAsStream())
|
||||||
|
@ -39,7 +39,8 @@ interface FileService : Service {
|
|||||||
targetRemotePath: String,
|
targetRemotePath: String,
|
||||||
sourceSpaceWebDavUrl: String?,
|
sourceSpaceWebDavUrl: String?,
|
||||||
targetSpaceWebDavUrl: String?,
|
targetSpaceWebDavUrl: String?,
|
||||||
): RemoteOperationResult<String>
|
replace: Boolean,
|
||||||
|
): RemoteOperationResult<String?>
|
||||||
|
|
||||||
fun createFolder(
|
fun createFolder(
|
||||||
remotePath: String,
|
remotePath: String,
|
||||||
|
@ -54,12 +54,14 @@ class OCFileService(override val client: OwnCloudClient) : FileService {
|
|||||||
targetRemotePath: String,
|
targetRemotePath: String,
|
||||||
sourceSpaceWebDavUrl: String?,
|
sourceSpaceWebDavUrl: String?,
|
||||||
targetSpaceWebDavUrl: String?,
|
targetSpaceWebDavUrl: String?,
|
||||||
): RemoteOperationResult<String> =
|
replace: Boolean,
|
||||||
|
): RemoteOperationResult<String?> =
|
||||||
CopyRemoteFileOperation(
|
CopyRemoteFileOperation(
|
||||||
sourceRemotePath = sourceRemotePath,
|
sourceRemotePath = sourceRemotePath,
|
||||||
targetRemotePath = targetRemotePath,
|
targetRemotePath = targetRemotePath,
|
||||||
sourceSpaceWebDavUrl = sourceSpaceWebDavUrl,
|
sourceSpaceWebDavUrl = sourceSpaceWebDavUrl,
|
||||||
targetSpaceWebDavUrl = targetSpaceWebDavUrl,
|
targetSpaceWebDavUrl = targetSpaceWebDavUrl,
|
||||||
|
forceOverride = replace,
|
||||||
).execute(client)
|
).execute(client)
|
||||||
|
|
||||||
override fun createFolder(
|
override fun createFolder(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user