Show failed migrations instead of waiting on them forever
This commit is contained in:
@@ -179,6 +179,9 @@ class MainActivity : BaseActivity() {
|
||||
Migrator.awaitAndRelease()
|
||||
isAppMigrating.value = false
|
||||
}
|
||||
// Uncaught on purpose: a failed database migration otherwise leaves the migrating screen up for good,
|
||||
// while the crash screen tells what went wrong and lets the logs be shared
|
||||
lifecycleScope.launch { databaseRepository.awaitOpen() }
|
||||
|
||||
// Do not let the launcher create a new activity http://stackoverflow.com/questions/16283079
|
||||
if (!isTaskRoot) {
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package mihon.core.migration
|
||||
|
||||
import kotlinx.coroutines.CancellationException
|
||||
import kotlinx.coroutines.CompletableDeferred
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Deferred
|
||||
import kotlinx.coroutines.async
|
||||
import logcat.LogPriority
|
||||
import tachiyomi.core.common.util.system.logcat
|
||||
|
||||
class MigrationJobFactory(
|
||||
@@ -20,7 +22,18 @@ class MigrationJobFactory(
|
||||
}
|
||||
async {
|
||||
val prev = acc.await()
|
||||
migration(migrationContext) || prev
|
||||
// A failure would cancel the rest of the chain and leave the app waiting on it for good
|
||||
val ran = try {
|
||||
migration(migrationContext)
|
||||
} catch (e: CancellationException) {
|
||||
throw e
|
||||
} catch (e: Exception) {
|
||||
logcat(LogPriority.ERROR, e) {
|
||||
"Migration failed: { name = ${migration::class.simpleName}, version = ${migration.version} }"
|
||||
}
|
||||
false
|
||||
}
|
||||
ran || prev
|
||||
}
|
||||
} else {
|
||||
logcat {
|
||||
|
||||
Reference in New Issue
Block a user