From 682989599517252d92fb639000ff87a0641bd12e Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Fri, 21 May 2021 09:08:16 +1000 Subject: [PATCH] Handle Kryo version incompatibility --- .../securesms/database/helpers/SQLCipherOpenHelper.java | 9 ++++++++- .../securesms/loki/database/SessionJobDatabase.kt | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/helpers/SQLCipherOpenHelper.java b/app/src/main/java/org/thoughtcrime/securesms/database/helpers/SQLCipherOpenHelper.java index 034fd7f521..d6c62f8f15 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/helpers/SQLCipherOpenHelper.java +++ b/app/src/main/java/org/thoughtcrime/securesms/database/helpers/SQLCipherOpenHelper.java @@ -56,9 +56,10 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper { private static final int lokiV22 = 43; private static final int lokiV23 = 44; private static final int lokiV24 = 45; + private static final int lokiV25 = 46; // Loki - onUpgrade(...) must be updated to use Loki version numbers if Signal makes any database changes - private static final int DATABASE_VERSION = lokiV24; + private static final int DATABASE_VERSION = lokiV25; private static final String DATABASE_NAME = "signal.db"; private final Context context; @@ -291,6 +292,12 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper { db.execSQL(LokiAPIDatabase.getCreateSwarmTableCommand()); } + if (oldVersion < lokiV25) { + String jobTable = SessionJobDatabase.sessionJobTable; + db.execSQL("DROP TABLE " + jobTable); + db.execSQL(SessionJobDatabase.getCreateSessionJobTableCommand()); + } + db.setTransactionSuccessful(); } finally { db.endTransaction(); diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/database/SessionJobDatabase.kt b/app/src/main/java/org/thoughtcrime/securesms/loki/database/SessionJobDatabase.kt index 55409e1a5e..6d070865ac 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/database/SessionJobDatabase.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/loki/database/SessionJobDatabase.kt @@ -14,7 +14,7 @@ import org.thoughtcrime.securesms.loki.utilities.* class SessionJobDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(context, helper) { companion object { - private const val sessionJobTable = "session_job_database" + const val sessionJobTable = "session_job_database" const val jobID = "job_id" const val jobType = "job_type" const val failureCount = "failure_count"