Skip to content

Commit

Permalink
fix: DiskReadViolation related database check (#2276)
Browse files Browse the repository at this point in the history
  • Loading branch information
ohassine committed Sep 27, 2023
1 parent f65934a commit 4750dbe
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 4750dbe

Please sign in to comment.