mirror of
https://github.com/android-password-store/Android-Password-Store
synced 2025-09-01 23:05:33 +00:00
fix(ssh): make SSHKeyManager.keyExists
infallible
This commit is contained in:
@@ -25,6 +25,7 @@ import app.passwordstore.ssh.writer.ED25519KeyWriter
|
|||||||
import app.passwordstore.ssh.writer.ImportedKeyWriter
|
import app.passwordstore.ssh.writer.ImportedKeyWriter
|
||||||
import app.passwordstore.ssh.writer.KeystoreNativeKeyWriter
|
import app.passwordstore.ssh.writer.KeystoreNativeKeyWriter
|
||||||
import com.github.michaelbull.result.getOrElse
|
import com.github.michaelbull.result.getOrElse
|
||||||
|
import com.github.michaelbull.result.mapBoth
|
||||||
import com.github.michaelbull.result.runCatching
|
import com.github.michaelbull.result.runCatching
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
@@ -65,12 +66,7 @@ public class SSHKeyManager(private val applicationContext: Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public fun keyExists(): Boolean {
|
public fun keyExists(): Boolean {
|
||||||
return try {
|
return runCatching { keyType() }.mapBoth(success = { true }, failure = { false })
|
||||||
keyType()
|
|
||||||
true
|
|
||||||
} catch (e: IllegalStateException) {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public fun canShowPublicKey(): Boolean =
|
public fun canShowPublicKey(): Boolean =
|
||||||
|
Reference in New Issue
Block a user