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