From e2900c26de9e9c96312ad860bce07383692760d1 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Sat, 25 Mar 2023 12:16:16 +0530 Subject: fix: use DispatcherProvider in CryptoRepository --- .../main/java/app/passwordstore/data/crypto/CryptoRepository.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'app/src/main/java') 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, content: ByteArrayInputStream, out: ByteArrayOutputStream, - ) = withContext(Dispatchers.IO) { encryptPgp(identities, content, out) } + ) = withContext(dispatcherProvider.io()) { encryptPgp(identities, content, out) } private suspend fun decryptPgp( password: String, -- cgit v1.2.3