Fix UI freeze after migration

Fixes #938

(cherry picked from commit 3f1d28c3833e6b868152149ed02b3fb8c54eccef)
This commit is contained in:
AntsyLich 2024-08-12 03:21:17 +06:00 committed by Jobobby04
parent 49bdffdc28
commit c137bafd68
2 changed files with 2 additions and 4 deletions

View File

@ -6,15 +6,13 @@ class MigrationStrategyFactory(
) { ) {
fun create(old: Int, new: Int): MigrationStrategy { fun create(old: Int, new: Int): MigrationStrategy {
val versions = (old + 1)..new
val strategy = when { val strategy = when {
old == 0 -> InitialMigrationStrategy( old == 0 -> InitialMigrationStrategy(
strategy = DefaultMigrationStrategy(factory, migrationCompletedListener, Migrator.scope), strategy = DefaultMigrationStrategy(factory, migrationCompletedListener, Migrator.scope),
) )
old >= new -> NoopMigrationStrategy(false) old >= new -> NoopMigrationStrategy(false)
else -> VersionRangeMigrationStrategy( else -> VersionRangeMigrationStrategy(
versions = versions, versions = (old + 1)..new,
strategy = DefaultMigrationStrategy(factory, migrationCompletedListener, Migrator.scope), strategy = DefaultMigrationStrategy(factory, migrationCompletedListener, Migrator.scope),
) )
} }

View File

@ -10,7 +10,7 @@ import kotlinx.coroutines.runBlocking
object Migrator { object Migrator {
private var result: Deferred<Boolean>? = null private var result: Deferred<Boolean>? = null
val scope = CoroutineScope(Dispatchers.Main + Job()) val scope = CoroutineScope(Dispatchers.IO + Job())
fun initialize( fun initialize(
old: Int, old: Int,