diff --git a/app/src/main/java/com/nextcloud/talk/utils/PushUtils.kt b/app/src/main/java/com/nextcloud/talk/utils/PushUtils.kt index 7c48eae98..95e59b214 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/PushUtils.kt +++ b/app/src/main/java/com/nextcloud/talk/utils/PushUtils.kt @@ -117,15 +117,14 @@ class PushUtils { private fun saveKeyToFile(key: Key, path: String): Int { val encoded = key.encoded try { - if (!File(path).exists()) { - if (!File(path).createNewFile()) { - return -1 + return if (!File(path).exists() && !File(path).createNewFile()) { + -1 + } else { + FileOutputStream(path).use { keyFileOutputStream -> + keyFileOutputStream.write(encoded) + 0 } } - FileOutputStream(path).use { keyFileOutputStream -> - keyFileOutputStream.write(encoded) - return 0 - } } catch (e: FileNotFoundException) { Log.d(TAG, "Failed to save key to file") } catch (e: IOException) { diff --git a/detekt.yml b/detekt.yml index feafeb301..7ad14df30 100644 --- a/detekt.yml +++ b/detekt.yml @@ -1,7 +1,7 @@ # SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors # SPDX-License-Identifier: GPL-3.0-or-later build: - maxIssues: 83 + maxIssues: 82 weights: # complexity: 2 # LongParameterList: 1