kopia lustrzana https://github.com/ryukoposting/Signal-Android
Guard against potentially double-running a migration.
rodzic
4c318d8d82
commit
08f1ddb212
|
@ -168,6 +168,7 @@ open class SignalDatabase(private val context: Application, databaseSecret: Data
|
||||||
db.beginTransaction()
|
db.beginTransaction()
|
||||||
try {
|
try {
|
||||||
migrate(context, db, oldVersion, newVersion)
|
migrate(context, db, oldVersion, newVersion)
|
||||||
|
db.version = newVersion
|
||||||
db.setTransactionSuccessful()
|
db.setTransactionSuccessful()
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction()
|
db.endTransaction()
|
||||||
|
|
|
@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.database.helpers.migration
|
||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import net.zetetic.database.sqlcipher.SQLiteDatabase
|
import net.zetetic.database.sqlcipher.SQLiteDatabase
|
||||||
|
import org.signal.core.util.SqlUtil
|
||||||
import org.signal.core.util.Stopwatch
|
import org.signal.core.util.Stopwatch
|
||||||
import org.signal.core.util.delete
|
import org.signal.core.util.delete
|
||||||
import org.signal.core.util.logging.Log
|
import org.signal.core.util.logging.Log
|
||||||
|
@ -19,6 +20,13 @@ object V166_ThreadAndMessageForeignKeys : SignalDatabaseMigration {
|
||||||
private val TAG = Log.tag(V166_ThreadAndMessageForeignKeys::class.java)
|
private val TAG = Log.tag(V166_ThreadAndMessageForeignKeys::class.java)
|
||||||
|
|
||||||
override fun migrate(context: Application, db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
|
override fun migrate(context: Application, db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
|
||||||
|
// Some crashes we were seeing indicated that we may have been running this migration twice on some unlucky devices, likely due
|
||||||
|
// to some gaps that were left between some transactions during the upgrade path.
|
||||||
|
if (!SqlUtil.columnExists(db, "thread", "thread_recipient_id")) {
|
||||||
|
Log.w(TAG, "Migration must have already run! Skipping.")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
val stopwatch = Stopwatch("migration")
|
val stopwatch = Stopwatch("migration")
|
||||||
|
|
||||||
removeDuplicateThreadEntries(db)
|
removeDuplicateThreadEntries(db)
|
||||||
|
|
Ładowanie…
Reference in New Issue