1
0
mirror of https://github.com/owncloud/android-library.git synced 2025-06-07 07:56:19 +00:00

Solving bug when copyin or moving

This commit is contained in:
Manuel Plazas Palacio 2023-08-22 15:24:59 +02:00
parent 1f8de383b6
commit bf183fe04d
2 changed files with 7 additions and 5 deletions

View File

@ -27,6 +27,7 @@ import com.owncloud.android.lib.common.OwnCloudClient
import com.owncloud.android.lib.common.http.HttpConstants
import com.owncloud.android.lib.common.http.methods.webdav.DavUtils.allPropSet
import com.owncloud.android.lib.common.http.methods.webdav.PropfindMethod
import com.owncloud.android.lib.common.network.WebdavUtils
import com.owncloud.android.lib.common.operations.RemoteOperation
import com.owncloud.android.lib.common.operations.RemoteOperationResult
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode
@ -53,11 +54,12 @@ class CheckPathExistenceRemoteOperation(
) : RemoteOperation<Boolean>() {
override fun run(client: OwnCloudClient): RemoteOperationResult<Boolean> {
val baseStringUrl = spaceWebDavUrl ?: if (isUserLoggedIn) client.baseFilesWebDavUri.toString()
val baseStringUrl = spaceWebDavUrl ?: if (isUserLoggedIn) client.baseFilesWebDavUri.toString() + WebdavUtils.encodePath(remotePath)
else client.userFilesWebDavUri.toString()
val stringUrl = if (isUserLoggedIn) baseStringUrl + WebdavUtils.encodePath(remotePath) else baseStringUrl
return try {
val propFindMethod = PropfindMethod(URL(baseStringUrl), 0, allPropSet).apply {
val propFindMethod = PropfindMethod(URL(stringUrl), 0, allPropSet).apply {
setReadTimeout(TIMEOUT.toLong(), TimeUnit.SECONDS)
setConnectionTimeout(TIMEOUT.toLong(), TimeUnit.SECONDS)
}
@ -68,7 +70,7 @@ class CheckPathExistenceRemoteOperation(
* 207 MULTI_STATUS: path exists.
*/
Timber.d(
"Existence check for $baseStringUrl finished with HTTP status $status${if (!isSuccess(status)) "(FAIL)" else ""}"
"Existence check for $stringUrl finished with HTTP status $status${if (!isSuccess(status)) "(FAIL)" else ""}"
)
if (isSuccess(status)) RemoteOperationResult<Boolean>(ResultCode.OK).apply { data = true }
else RemoteOperationResult<Boolean>(propFindMethod).apply { data = false }
@ -77,7 +79,7 @@ class CheckPathExistenceRemoteOperation(
val result = RemoteOperationResult<Boolean>(e)
Timber.e(
e,
"Existence check for $baseStringUrl : ${result.logMessage}"
"Existence check for $stringUrl : ${result.logMessage}"
)
result
}

View File

@ -40,7 +40,7 @@ class OCServerInfoService : ServerInfoService {
): RemoteOperationResult<Boolean> =
CheckPathExistenceRemoteOperation(
remotePath = path,
isUserLoggedIn = true,
isUserLoggedIn = isUserLoggedIn,
).execute(client)
override fun getRemoteStatus(