fix detekt

Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
sowjanyakch 2025-02-28 13:13:56 +01:00 committed by Marcel Hibbe
parent 2ef4ff6e40
commit 546e6abec4
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B

View File

@ -49,19 +49,33 @@ class FileUploader(
fun upload(sourceFileUri: Uri, fileName: String, remotePath: String, metaData: String?): Observable<Boolean> { fun upload(sourceFileUri: Uri, fileName: String, remotePath: String, metaData: String?): Observable<Boolean> {
return ncApi.uploadFile( return ncApi.uploadFile(
ApiUtils.getCredentials(currentUser.username, currentUser.token), ApiUtils.getCredentials(
ApiUtils.getUrlForFileUpload(currentUser.baseUrl!!, currentUser.userId!!, remotePath), currentUser.username,
currentUser.token
),
ApiUtils.getUrlForFileUpload(
currentUser.baseUrl!!,
currentUser.userId!!,
remotePath
),
createRequestBody(sourceFileUri) createRequestBody(sourceFileUri)
) )
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.flatMap { response -> .flatMap { response ->
if (response.isSuccessful) { if (response.isSuccessful) {
ShareOperationWorker.shareFile(roomToken, currentUser, remotePath, metaData) ShareOperationWorker.shareFile(
roomToken,
currentUser,
remotePath,
metaData
)
FileUtils.copyFileToCache(context, sourceFileUri, fileName) FileUtils.copyFileToCache(context, sourceFileUri, fileName)
Observable.just(true) Observable.just(true)
} else { } else {
if (response.code() == HTTP_CODE_NOT_FOUND || response.code() == HTTP_CODE_CONFLICT) { if (response.code() == HTTP_CODE_NOT_FOUND ||
response.code() == HTTP_CODE_CONFLICT
) {
createDavResource(sourceFileUri, fileName, remotePath, metaData) createDavResource(sourceFileUri, fileName, remotePath, metaData)
} else { } else {
Observable.just(false) Observable.just(false)
@ -77,16 +91,25 @@ class FileUploader(
metaData: String? metaData: String?
): Observable<Boolean> { ): Observable<Boolean> {
return Observable.fromCallable { return Observable.fromCallable {
val userFileUploadPath = ApiUtils.userFileUploadPath(currentUser.baseUrl!!, currentUser.userId!!) val userFileUploadPath = ApiUtils.userFileUploadPath(
currentUser.baseUrl!!,
currentUser.userId!!
)
val userTalkAttachmentsUploadPath = ApiUtils.userTalkAttachmentsUploadPath( val userTalkAttachmentsUploadPath = ApiUtils.userTalkAttachmentsUploadPath(
currentUser.baseUrl!!, currentUser.baseUrl!!,
currentUser.userId!! currentUser.userId!!
) )
var davResource = DavResource(okHttpClientNoRedirects!!, userFileUploadPath.toHttpUrlOrNull()!!) var davResource = DavResource(
okHttpClientNoRedirects!!,
userFileUploadPath.toHttpUrlOrNull()!!
)
createFolder(davResource) createFolder(davResource)
initHttpClient(okHttpClient = okhttpClient, currentUser) initHttpClient(okHttpClient = okhttpClient, currentUser)
davResource = DavResource(okHttpClientNoRedirects!!, userTalkAttachmentsUploadPath.toHttpUrlOrNull()!!) davResource = DavResource(
okHttpClientNoRedirects!!,
userTalkAttachmentsUploadPath.toHttpUrlOrNull()!!
)
createFolder(davResource) createFolder(davResource)
true true
} }
@ -128,6 +151,7 @@ class FileUploader(
this.okHttpClientNoRedirects = okHttpClientBuilder.build() this.okHttpClientNoRedirects = okHttpClientBuilder.build()
} }
@Suppress("Detekt.ThrowsCount")
private fun createFolder(davResource: DavResource) { private fun createFolder(davResource: DavResource) {
try { try {
davResource.mkCol( davResource.mkCol(