mirror of
				https://github.com/owncloud/android-library.git
				synced 2025-10-31 02:17:41 +00:00 
			
		
		
		
	Support removal of files from specific space
This commit is contained in:
		
							parent
							
								
									2c18e7b679
								
							
						
					
					
						commit
						9c844aae7e
					
				| @ -68,13 +68,13 @@ class CreateRemoteFolderOperation( | ||||
|         var result: RemoteOperationResult<Unit> | ||||
|         try { | ||||
|             val webDavUri = if (isChunksFolder) { | ||||
|                 client.uploadsWebDavUri | ||||
|                 client.uploadsWebDavUri.toString() | ||||
|             } else { | ||||
|                 client.userFilesWebDavUri | ||||
|                 spaceWebDavUrl ?: client.userFilesWebDavUri.toString() | ||||
|             } | ||||
| 
 | ||||
|             val mkCol = MkColMethod( | ||||
|                 URL(webDavUri.toString() + WebdavUtils.encodePath(remotePath)) | ||||
|                 URL(webDavUri + WebdavUtils.encodePath(remotePath)) | ||||
|             ).apply { | ||||
|                 setReadTimeout(READ_TIMEOUT, TimeUnit.SECONDS) | ||||
|                 setConnectionTimeout(CONNECTION_TIMEOUT, TimeUnit.SECONDS) | ||||
|  | ||||
| @ -24,7 +24,6 @@ | ||||
| 
 | ||||
| package com.owncloud.android.lib.resources.files | ||||
| 
 | ||||
| import android.net.Uri | ||||
| import com.owncloud.android.lib.common.OwnCloudClient | ||||
| import com.owncloud.android.lib.common.http.HttpConstants.HTTP_NO_CONTENT | ||||
| import com.owncloud.android.lib.common.http.HttpConstants.HTTP_OK | ||||
| @ -46,7 +45,8 @@ import java.net.URL | ||||
|  * @author Abel García de Prada | ||||
|  */ | ||||
| open class RemoveRemoteFileOperation( | ||||
|     private val remotePath: String | ||||
|     private val remotePath: String, | ||||
|     val spaceWebDavUrl: String? = null, | ||||
| ) : RemoteOperation<Unit>() { | ||||
| 
 | ||||
|     override fun run(client: OwnCloudClient): RemoteOperationResult<Unit> { | ||||
| @ -54,7 +54,7 @@ open class RemoveRemoteFileOperation( | ||||
|         try { | ||||
|             val srcWebDavUri = getSrcWebDavUriForClient(client) | ||||
|             val deleteMethod = DeleteMethod( | ||||
|                 URL(srcWebDavUri.toString() + WebdavUtils.encodePath(remotePath)) | ||||
|                 URL(srcWebDavUri + WebdavUtils.encodePath(remotePath)) | ||||
|             ) | ||||
|             val status = client.executeHttpMethod(deleteMethod) | ||||
| 
 | ||||
| @ -75,7 +75,7 @@ open class RemoveRemoteFileOperation( | ||||
|      * For standard removals, we will use [OwnCloudClient.getUserFilesWebDavUri]. | ||||
|      * In case we need a different source Uri, override this method. | ||||
|      */ | ||||
|     open fun getSrcWebDavUriForClient(client: OwnCloudClient): Uri = client.userFilesWebDavUri | ||||
|     open fun getSrcWebDavUriForClient(client: OwnCloudClient): String = spaceWebDavUrl ?: client.userFilesWebDavUri.toString() | ||||
| 
 | ||||
|     private fun isSuccess(status: Int) = status.isOneOf(HTTP_OK, HTTP_NO_CONTENT) | ||||
| } | ||||
|  | ||||
| @ -24,10 +24,9 @@ | ||||
|  */ | ||||
| package com.owncloud.android.lib.resources.files.chunks | ||||
| 
 | ||||
| import android.net.Uri | ||||
| import com.owncloud.android.lib.common.OwnCloudClient | ||||
| import com.owncloud.android.lib.resources.files.RemoveRemoteFileOperation | ||||
| 
 | ||||
| class RemoveRemoteChunksFolderOperation(remotePath: String) : RemoveRemoteFileOperation(remotePath) { | ||||
|     override fun getSrcWebDavUriForClient(client: OwnCloudClient): Uri = client.uploadsWebDavUri | ||||
|     override fun getSrcWebDavUriForClient(client: OwnCloudClient): String = client.uploadsWebDavUri.toString() | ||||
| } | ||||
|  | ||||
| @ -68,7 +68,8 @@ interface FileService : Service { | ||||
|     ): RemoteOperationResult<ArrayList<RemoteFile>> | ||||
| 
 | ||||
|     fun removeFile( | ||||
|         remotePath: String | ||||
|         remotePath: String, | ||||
|         spaceWebDavUrl: String? = null, | ||||
|     ): RemoteOperationResult<Unit> | ||||
| 
 | ||||
|     fun renameFile( | ||||
|  | ||||
| @ -111,10 +111,12 @@ class OCFileService(override val client: OwnCloudClient) : FileService { | ||||
|         ).execute(client) | ||||
| 
 | ||||
|     override fun removeFile( | ||||
|         remotePath: String | ||||
|         remotePath: String, | ||||
|         spaceWebDavUrl: String?, | ||||
|     ): RemoteOperationResult<Unit> = | ||||
|         RemoveRemoteFileOperation( | ||||
|             remotePath = remotePath | ||||
|             remotePath = remotePath, | ||||
|             spaceWebDavUrl = spaceWebDavUrl, | ||||
|         ).execute(client) | ||||
| 
 | ||||
|     override fun renameFile( | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user