mirror of
				https://github.com/owncloud/android-library.git
				synced 2025-10-31 02:17:41 +00:00 
			
		
		
		
	Apply CR changes
This commit is contained in:
		
							parent
							
								
									eaa88b7ca0
								
							
						
					
					
						commit
						d900ca3ba9
					
				| @ -0,0 +1,29 @@ | ||||
| /* ownCloud Android Library is available under MIT license | ||||
|  *   Copyright (C) 2020 ownCloud GmbH. | ||||
|  * | ||||
|  *   Permission is hereby granted, free of charge, to any person obtaining a copy | ||||
|  *   of this software and associated documentation files (the "Software"), to deal | ||||
|  *   in the Software without restriction, including without limitation the rights | ||||
|  *   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||
|  *   copies of the Software, and to permit persons to whom the Software is | ||||
|  *   furnished to do so, subject to the following conditions: | ||||
|  * | ||||
|  *   The above copyright notice and this permission notice shall be included in | ||||
|  *   all copies or substantial portions of the Software. | ||||
|  * | ||||
|  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||||
|  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||||
|  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||||
|  *   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||||
|  *   BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||||
|  *   ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||||
|  *   CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||||
|  *   THE SOFTWARE. | ||||
|  * | ||||
|  */ | ||||
| 
 | ||||
| package com.owncloud.android.lib.common.utils | ||||
| 
 | ||||
| fun Any.isOneOf(vararg values: Any): Boolean { | ||||
|     return this in values | ||||
| } | ||||
| @ -26,7 +26,8 @@ package com.owncloud.android.lib.resources.files | ||||
| import at.bitfire.dav4jvm.PropertyRegistry | ||||
| import com.owncloud.android.lib.common.OwnCloudClient | ||||
| import com.owncloud.android.lib.common.accounts.AccountUtils | ||||
| import com.owncloud.android.lib.common.http.HttpConstants | ||||
| import com.owncloud.android.lib.common.http.HttpConstants.HTTP_MULTI_STATUS | ||||
| import com.owncloud.android.lib.common.http.HttpConstants.HTTP_OK | ||||
| import com.owncloud.android.lib.common.http.methods.webdav.DavConstants | ||||
| import com.owncloud.android.lib.common.http.methods.webdav.DavUtils | ||||
| import com.owncloud.android.lib.common.http.methods.webdav.PropfindMethod | ||||
| @ -35,6 +36,7 @@ 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 | ||||
| import com.owncloud.android.lib.common.utils.isOneOf | ||||
| import timber.log.Timber | ||||
| import java.net.URL | ||||
| 
 | ||||
| @ -105,6 +107,5 @@ class ReadRemoteFolderOperation( | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     private fun isSuccess(status: Int): Boolean = | ||||
|         status == HttpConstants.HTTP_MULTI_STATUS || status == HttpConstants.HTTP_OK | ||||
|     private fun isSuccess(status: Int): Boolean = status.isOneOf(HTTP_OK, HTTP_MULTI_STATUS) | ||||
| } | ||||
|  | ||||
| @ -43,6 +43,7 @@ import com.owncloud.android.lib.common.http.methods.webdav.properties.OCShareTyp | ||||
| import com.owncloud.android.lib.resources.shares.ShareType | ||||
| import com.owncloud.android.lib.resources.shares.ShareType.Companion.fromValue | ||||
| import kotlinx.parcelize.Parcelize | ||||
| import com.owncloud.android.lib.common.utils.isOneOf | ||||
| import okhttp3.HttpUrl | ||||
| import timber.log.Timber | ||||
| import java.io.File | ||||
| @ -78,7 +79,9 @@ data class RemoteFile( | ||||
| 
 | ||||
|     // TODO: Quotas not used. Use or remove them. | ||||
|     init { | ||||
|         require(!(remotePath.isEmpty() || !remotePath.startsWith(File.separator))) { "Trying to create a OCFile with a non valid remote path: $remotePath" } | ||||
|         require( | ||||
|             !(remotePath.isEmpty() || !remotePath.startsWith(File.separator)) | ||||
|         ) { "Trying to create a OCFile with a non valid remote path: $remotePath" } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
| @ -87,7 +90,7 @@ data class RemoteFile( | ||||
|      * @return true if it is a folder | ||||
|      */ | ||||
|     val isFolder | ||||
|         get() = mimeType == MIME_DIR || mimeType == MIME_DIR_UNIX | ||||
|         get() = mimeType.isOneOf(MIME_DIR, MIME_DIR_UNIX) | ||||
| 
 | ||||
|     companion object { | ||||
| 
 | ||||
| @ -167,7 +170,7 @@ data class RemoteFile( | ||||
|         private fun getRemotePathFromUrl(url: HttpUrl, userId: String): String { | ||||
|             val davFilesPath = OwnCloudClient.WEBDAV_FILES_PATH_4_0 + userId | ||||
|             val absoluteDavPath = Uri.decode(url.encodedPath) | ||||
|             val pathToOc = absoluteDavPath.split(davFilesPath)[0] | ||||
|             val pathToOc = absoluteDavPath.split(davFilesPath).first() | ||||
|             return absoluteDavPath.replace(pathToOc + davFilesPath, "") | ||||
|         } | ||||
|     } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user