summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2023-03-25 12:16:16 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2023-03-25 12:26:01 +0530
commite2900c26de9e9c96312ad860bce07383692760d1 (patch)
tree42ea63c028c38b44de5b2d0850bc69b8851ab92c /app
parentf07bfb2f975d91b133b7c094737d8455ea141239 (diff)
fix: use DispatcherProvider in CryptoRepository
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/app/passwordstore/data/crypto/CryptoRepository.kt7
1 files changed, 4 insertions, 3 deletions
diff --git a/app/src/main/java/app/passwordstore/data/crypto/CryptoRepository.kt b/app/src/main/java/app/passwordstore/data/crypto/CryptoRepository.kt
index f3a82f39..fae13f21 100644
--- a/app/src/main/java/app/passwordstore/data/crypto/CryptoRepository.kt
+++ b/app/src/main/java/app/passwordstore/data/crypto/CryptoRepository.kt
@@ -13,6 +13,7 @@ import app.passwordstore.crypto.PGPKeyManager
import app.passwordstore.crypto.PGPainlessCryptoHandler
import app.passwordstore.crypto.errors.CryptoHandlerException
import app.passwordstore.injection.prefs.SettingsPreferences
+import app.passwordstore.util.coroutines.DispatcherProvider
import app.passwordstore.util.settings.PreferenceKeys
import com.github.michaelbull.result.Result
import com.github.michaelbull.result.getAll
@@ -20,7 +21,6 @@ import com.github.michaelbull.result.unwrap
import java.io.ByteArrayInputStream
import java.io.ByteArrayOutputStream
import javax.inject.Inject
-import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
class CryptoRepository
@@ -28,6 +28,7 @@ class CryptoRepository
constructor(
private val pgpKeyManager: PGPKeyManager,
private val pgpCryptoHandler: PGPainlessCryptoHandler,
+ private val dispatcherProvider: DispatcherProvider,
@SettingsPreferences private val settings: SharedPreferences,
) {
@@ -35,13 +36,13 @@ constructor(
password: String,
message: ByteArrayInputStream,
out: ByteArrayOutputStream,
- ) = withContext(Dispatchers.IO) { decryptPgp(password, message, out) }
+ ) = withContext(dispatcherProvider.io()) { decryptPgp(password, message, out) }
suspend fun encrypt(
identities: List<GpgIdentifier>,
content: ByteArrayInputStream,
out: ByteArrayOutputStream,
- ) = withContext(Dispatchers.IO) { encryptPgp(identities, content, out) }
+ ) = withContext(dispatcherProvider.io()) { encryptPgp(identities, content, out) }
private suspend fun decryptPgp(
password: String,