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 |  * @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}") | ||||||
|                     } |                     } | ||||||
|                 Timber.i("Get quota completed: ${result.data} and message: ${result.logMessage}") |  | ||||||
| 
 |  | ||||||
|                 } else { // synchronization failed |                 } else { // synchronization failed | ||||||
|                 result = RemoteOperationResult(propfindMethod) |                     RemoteOperationResult<RemoteQuota>(propfindMethod).also { | ||||||
|                 Timber.e("Get quota without success: ${result.logMessage}") |                         Timber.e("Get quota without success: ${it.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