Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 019891cd authored by ZetaTom's avatar ZetaTom
Browse files

Fix lint



- remove redundant exception handling

Signed-off-by: default avatarZetaTom <70907959+ZetaTom@users.noreply.github.com>
parent abc9c21b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ class FilesDownloadLimitIT : AbstractIT() {
    }

    @Test
    @Suppress("Detekt.MagicNumber")
    fun downloadLimit() {
        val share = createTestShare()
        val limit = 5
+18 −23
Original line number Diff line number Diff line
@@ -26,8 +26,7 @@ class GetFilesDownloadLimitRemoteOperation
    ) : OCSRemoteOperation<List<FileDownloadLimit>>() {
        @Deprecated("Deprecated in Java")
        override fun run(client: OwnCloudClient): RemoteOperationResult<List<FileDownloadLimit>> {
            var result: RemoteOperationResult<List<FileDownloadLimit>>
            var propFindMethod: PropFindMethod? = null
            val result: RemoteOperationResult<List<FileDownloadLimit>>
            val propSet = DavPropertyNameSet()
            val depth = if (subfiles) DavConstants.DEPTH_1 else DavConstants.DEPTH_0

@@ -36,8 +35,7 @@ class GetFilesDownloadLimitRemoteOperation
                Namespace.getNamespace(WebdavEntry.NAMESPACE_NC)
            )

            try {
                propFindMethod = PropFindMethod(client.getFilesDavUri(remotePath), propSet, depth)
            val propFindMethod = PropFindMethod(client.getFilesDavUri(remotePath), propSet, depth)

            val status = client.executeMethod(propFindMethod)

@@ -53,15 +51,12 @@ class GetFilesDownloadLimitRemoteOperation
                result = RemoteOperationResult(true, propFindMethod)
                result.resultData = fileDownloadLimits
            } else {
                Log_OC.e(TAG, "Failed to get download limit")
                result = RemoteOperationResult(false, propFindMethod)
                client.exhaustResponse(propFindMethod.responseBodyAsStream)
            }
            } catch (e: Exception) {
                result = RemoteOperationResult(e)
                Log_OC.e(TAG, "Exception while reading download limit", e)
            } finally {
                propFindMethod?.releaseConnection()
            }

            propFindMethod.releaseConnection()

            return result
        }
+15 −21
Original line number Diff line number Diff line
@@ -18,12 +18,10 @@ class RemoveFilesDownloadLimitRemoteOperation(
    val token: String
) : OCSRemoteOperation<Void>() {
    override fun run(client: NextcloudClient): RemoteOperationResult<Void> {
        var result: RemoteOperationResult<Void>
        var deleteMethod: DeleteMethod? = null
        val result: RemoteOperationResult<Void>

        try {
        val url = client.baseUri.toString() + String.format(FILES_DOWNLOAD_LIMIT_ENDPOINT, token) + JSON_FORMAT
            deleteMethod = DeleteMethod(url, true)
        val deleteMethod = DeleteMethod(url, true)

        val status = deleteMethod.execute(client)

@@ -34,12 +32,8 @@ class RemoveFilesDownloadLimitRemoteOperation(
            Log_OC.e(TAG, "Failed to remove download limit")
            Log_OC.e(TAG, "*** status code: " + status + "; response: " + deleteMethod.getResponseBodyAsString())
        }
        } catch (e: Exception) {
            result = RemoteOperationResult(e)
            Log_OC.e(TAG, "Exception while removing download limit", e)
        } finally {
            deleteMethod?.releaseConnection()
        }

        deleteMethod.releaseConnection()

        return result
    }
+16 −22
Original line number Diff line number Diff line
@@ -20,13 +20,11 @@ class SetFilesDownloadLimitRemoteOperation(
    val limit: Int
) : OCSRemoteOperation<Void>() {
    override fun run(client: NextcloudClient): RemoteOperationResult<Void> {
        var result: RemoteOperationResult<Void>
        var putMethod: PutMethod? = null
        val result: RemoteOperationResult<Void>

        try {
        val url = client.baseUri.toString() + String.format(FILES_DOWNLOAD_LIMIT_ENDPOINT, token)
        val jsonRequestBody = JSONRequestBody("limit", limit.toString())
            putMethod = PutMethod(url, true, jsonRequestBody.get())
        val putMethod = PutMethod(url, true, jsonRequestBody.get())

        val status = putMethod.execute(client)

@@ -37,12 +35,8 @@ class SetFilesDownloadLimitRemoteOperation(
            Log_OC.e(TAG, "Failed to set download limit")
            Log_OC.e(TAG, "*** status code: " + status + "; response: " + putMethod.getResponseBodyAsString())
        }
        } catch (e: Exception) {
            result = RemoteOperationResult(e)
            Log_OC.e(TAG, "Exception while setting download limit", e)
        } finally {
            putMethod?.releaseConnection()
        }

        putMethod.releaseConnection()

        return result
    }