From d4a4ac06ed419221d3a1f967ca3a66b1e163ddb8 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Wed, 27 Apr 2022 22:32:36 +0530 Subject: crypto-pgpainless: prepare for error handling (#1877) --- app/src/main/java/dev/msfjarvis/aps/data/crypto/CryptoRepository.kt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'app') diff --git a/app/src/main/java/dev/msfjarvis/aps/data/crypto/CryptoRepository.kt b/app/src/main/java/dev/msfjarvis/aps/data/crypto/CryptoRepository.kt index 2923b117..0e262e7a 100644 --- a/app/src/main/java/dev/msfjarvis/aps/data/crypto/CryptoRepository.kt +++ b/app/src/main/java/dev/msfjarvis/aps/data/crypto/CryptoRepository.kt @@ -5,7 +5,6 @@ package dev.msfjarvis.aps.data.crypto -import com.github.michaelbull.result.runCatching import com.github.michaelbull.result.unwrap import dev.msfjarvis.aps.crypto.PGPKeyManager import dev.msfjarvis.aps.crypto.PGPainlessCryptoHandler @@ -42,9 +41,7 @@ constructor( ) { val keys = pgpKeyManager.getAllKeys().unwrap() // Iterates through the keys until the first successful decryption, then returns. - keys.firstOrNull { key -> - runCatching { pgpCryptoHandler.decrypt(key, password, message, out) }.isOk() - } + keys.firstOrNull { key -> pgpCryptoHandler.decrypt(key, password, message, out).isOk() } } private suspend fun encryptPgp(content: ByteArrayInputStream, out: ByteArrayOutputStream) { -- cgit v1.2.3