From eef2f6b438d0842ba7ea0a3327e490a1d85e39b9 Mon Sep 17 00:00:00 2001 From: Oussama Hassine Date: Wed, 27 Sep 2023 14:33:32 +0200 Subject: [PATCH] fix: some DiskReadViolation --- .../com/wire/android/migration/MigrationManager.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/wire/android/migration/MigrationManager.kt b/app/src/main/kotlin/com/wire/android/migration/MigrationManager.kt index 67a62ab437c..287213e67a5 100644 --- a/app/src/main/kotlin/com/wire/android/migration/MigrationManager.kt +++ b/app/src/main/kotlin/com/wire/android/migration/MigrationManager.kt @@ -71,6 +71,7 @@ import kotlinx.coroutines.Job import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.joinAll import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.ConcurrentMap import javax.inject.Inject @@ -91,9 +92,11 @@ class MigrationManager @Inject constructor( private val markUsersAsNeedToBeMigrated: MarkUsersAsNeedToBeMigrated, private val notificationManager: NotificationManager ) { - private fun isScalaDBPresent(): Boolean = - applicationContext.getDatabasePath(ScalaDBNameProvider.globalDB()).let { it.isFile && it.exists() } - + private suspend fun isScalaDBPresent(): Boolean = withContext(Dispatchers.IO) { + applicationContext + .getDatabasePath(ScalaDBNameProvider.globalDB()) + .let { it.isFile && it.exists() } + } suspend fun shouldMigrate(): Boolean = when { // already migrated globalDataStore.isMigrationCompleted() -> false