mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-07 16:06:08 +00:00
Apply CR suggestions
This commit is contained in:
parent
bbac8d0278
commit
8a88fbd938
@ -47,32 +47,31 @@ import kotlin.math.roundToLong
|
|||||||
* @author David González Verdugo
|
* @author David González Verdugo
|
||||||
*/
|
*/
|
||||||
class GetRemoteUserQuotaOperation : RemoteOperation<RemoteQuota>() {
|
class GetRemoteUserQuotaOperation : RemoteOperation<RemoteQuota>() {
|
||||||
override fun run(client: OwnCloudClient): RemoteOperationResult<RemoteQuota> {
|
override fun run(client: OwnCloudClient): RemoteOperationResult<RemoteQuota> =
|
||||||
lateinit var result: RemoteOperationResult<RemoteQuota>
|
|
||||||
try {
|
try {
|
||||||
val propfindMethod = PropfindMethod(
|
val propfindMethod = PropfindMethod(
|
||||||
URL(client.userFilesWebDavUri.toString()),
|
URL(client.userFilesWebDavUri.toString()),
|
||||||
DavConstants.DEPTH_0,
|
DavConstants.DEPTH_0,
|
||||||
DavUtils.getQuotaPropSet()
|
DavUtils.getQuotaPropSet()
|
||||||
)
|
)
|
||||||
val status = client.executeHttpMethod(propfindMethod)
|
with(client.executeHttpMethod(propfindMethod)) {
|
||||||
if (isSuccess(status)) {
|
if (isSuccess(this)) {
|
||||||
val remoteQuota = readData(propfindMethod.root.properties)
|
RemoteOperationResult<RemoteQuota>(ResultCode.OK).apply {
|
||||||
result = RemoteOperationResult<RemoteQuota>(ResultCode.OK).apply {
|
data = readData(propfindMethod.root.properties)
|
||||||
data = remoteQuota
|
}.also {
|
||||||
|
Timber.i("Get quota completed: ${it.data} and message: ${it.logMessage}")
|
||||||
|
}
|
||||||
|
} else { // synchronization failed
|
||||||
|
RemoteOperationResult<RemoteQuota>(propfindMethod).also {
|
||||||
|
Timber.e("Get quota without success: ${it.logMessage}")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Timber.i("Get quota completed: ${result.data} and message: ${result.logMessage}")
|
|
||||||
|
|
||||||
} else { // synchronization failed
|
|
||||||
result = RemoteOperationResult(propfindMethod)
|
|
||||||
Timber.e("Get quota without success: ${result.logMessage}")
|
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
result = RemoteOperationResult(e)
|
RemoteOperationResult<RemoteQuota>(e).also {
|
||||||
Timber.e(result.exception, "Get quota: ${result.logMessage}")
|
Timber.e(it.exception, "Get quota: ${it.logMessage}")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun isSuccess(status: Int) = status == HttpConstants.HTTP_MULTI_STATUS || status == HttpConstants.HTTP_OK
|
private fun isSuccess(status: Int) = status == HttpConstants.HTTP_MULTI_STATUS || status == HttpConstants.HTTP_OK
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user