mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-07 16:06:08 +00:00
Apply code review suggestions
This commit is contained in:
parent
332a5ac1cb
commit
bca1844403
@ -56,6 +56,7 @@ class CreateRemoteFolderOperation(
|
|||||||
result = createParentFolder(FileUtils.getParentPath(remotePath), client)
|
result = createParentFolder(FileUtils.getParentPath(remotePath), client)
|
||||||
|
|
||||||
if (result.isSuccess) {
|
if (result.isSuccess) {
|
||||||
|
// Second and last try
|
||||||
result = createFolder(client)
|
result = createFolder(client)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -65,25 +66,32 @@ class CreateRemoteFolderOperation(
|
|||||||
private fun createFolder(client: OwnCloudClient): RemoteOperationResult<Unit> {
|
private fun createFolder(client: OwnCloudClient): RemoteOperationResult<Unit> {
|
||||||
var result: RemoteOperationResult<Unit>
|
var result: RemoteOperationResult<Unit>
|
||||||
try {
|
try {
|
||||||
val webDavUri = if (isChunksFolder) client.uploadsWebDavUri else client.userFilesWebDavUri
|
val webDavUri = if (isChunksFolder) {
|
||||||
val mkcol = MkColMethod(URL(webDavUri.toString() + WebdavUtils.encodePath(remotePath))).apply {
|
client.uploadsWebDavUri
|
||||||
|
} else {
|
||||||
|
client.userFilesWebDavUri
|
||||||
|
}
|
||||||
|
|
||||||
|
val mkCol = MkColMethod(
|
||||||
|
URL(webDavUri.toString() + WebdavUtils.encodePath(remotePath))
|
||||||
|
).apply {
|
||||||
setReadTimeout(READ_TIMEOUT, TimeUnit.SECONDS)
|
setReadTimeout(READ_TIMEOUT, TimeUnit.SECONDS)
|
||||||
setConnectionTimeout(CONNECTION_TIMEOUT, TimeUnit.SECONDS)
|
setConnectionTimeout(CONNECTION_TIMEOUT, TimeUnit.SECONDS)
|
||||||
}
|
}
|
||||||
|
|
||||||
val status = client.executeHttpMethod(mkcol)
|
val status = client.executeHttpMethod(mkCol)
|
||||||
result =
|
result =
|
||||||
if (status == HttpConstants.HTTP_CREATED) {
|
if (status == HttpConstants.HTTP_CREATED) {
|
||||||
RemoteOperationResult<Unit>(ResultCode.OK)
|
RemoteOperationResult(ResultCode.OK)
|
||||||
} else {
|
} else {
|
||||||
RemoteOperationResult<Unit>(mkcol)
|
RemoteOperationResult(mkCol)
|
||||||
}
|
}
|
||||||
|
|
||||||
Timber.d("Create directory $remotePath: ${result.logMessage}")
|
Timber.d("Create directory $remotePath: ${result.logMessage}")
|
||||||
client.exhaustResponse(mkcol.getResponseBodyAsStream())
|
client.exhaustResponse(mkCol.getResponseBodyAsStream())
|
||||||
|
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
result = RemoteOperationResult<Unit>(e)
|
result = RemoteOperationResult(e)
|
||||||
Timber.e(e, "Create directory $remotePath: ${result.logMessage}")
|
Timber.e(e, "Create directory $remotePath: ${result.logMessage}")
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
|
@ -28,8 +28,20 @@ import com.owncloud.android.lib.resources.Service
|
|||||||
import com.owncloud.android.lib.resources.files.RemoteFile
|
import com.owncloud.android.lib.resources.files.RemoteFile
|
||||||
|
|
||||||
interface FileService : Service {
|
interface FileService : Service {
|
||||||
fun checkPathExistence(path: String, isUserLogged: Boolean): RemoteOperationResult<Boolean>
|
|
||||||
fun getUrlToOpenInWeb(openWebEndpoint: String, fileId: String): RemoteOperationResult<String>
|
fun getUrlToOpenInWeb(openWebEndpoint: String, fileId: String): RemoteOperationResult<String>
|
||||||
fun createFolder(remotePath: String, createFullPath: Boolean, isChunkFolder: Boolean = false): RemoteOperationResult<Unit>
|
|
||||||
fun refreshFolder(remotePath: String): RemoteOperationResult<ArrayList<RemoteFile>>
|
fun checkPathExistence(
|
||||||
|
path: String,
|
||||||
|
isUserLogged: Boolean
|
||||||
|
): RemoteOperationResult<Boolean>
|
||||||
|
|
||||||
|
fun createFolder(
|
||||||
|
remotePath: String,
|
||||||
|
createFullPath: Boolean,
|
||||||
|
isChunkFolder: Boolean = false
|
||||||
|
): RemoteOperationResult<Unit>
|
||||||
|
|
||||||
|
fun refreshFolder(
|
||||||
|
remotePath: String
|
||||||
|
): RemoteOperationResult<ArrayList<RemoteFile>>
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user