diff options
author | Harsh Shandilya <me@msfjarvis.dev> | 2023-05-19 18:42:01 +0530 |
---|---|---|
committer | Harsh Shandilya <me@msfjarvis.dev> | 2023-05-19 18:42:26 +0530 |
commit | 65509eaa54ea5fa8e363e3d6b1c044b1383a2c31 (patch) | |
tree | efaf8ebdf14df570ff3626a0422ef51ddff2a321 /ssh/src | |
parent | 648a450050bbd7ad14e3a8205c31e748b69cc285 (diff) |
fix(ssh): make `SSHKeyManager.keyExists` infallible
Diffstat (limited to 'ssh/src')
-rw-r--r-- | ssh/src/main/kotlin/app/passwordstore/ssh/SSHKeyManager.kt | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/ssh/src/main/kotlin/app/passwordstore/ssh/SSHKeyManager.kt b/ssh/src/main/kotlin/app/passwordstore/ssh/SSHKeyManager.kt index ad435f98..f30249c1 100644 --- a/ssh/src/main/kotlin/app/passwordstore/ssh/SSHKeyManager.kt +++ b/ssh/src/main/kotlin/app/passwordstore/ssh/SSHKeyManager.kt @@ -25,6 +25,7 @@ import app.passwordstore.ssh.writer.ED25519KeyWriter import app.passwordstore.ssh.writer.ImportedKeyWriter import app.passwordstore.ssh.writer.KeystoreNativeKeyWriter import com.github.michaelbull.result.getOrElse +import com.github.michaelbull.result.mapBoth import com.github.michaelbull.result.runCatching import java.io.File import java.io.IOException @@ -65,12 +66,7 @@ public class SSHKeyManager(private val applicationContext: Context) { } public fun keyExists(): Boolean { - return try { - keyType() - true - } catch (e: IllegalStateException) { - false - } + return runCatching { keyType() }.mapBoth(success = { true }, failure = { false }) } public fun canShowPublicKey(): Boolean = |