From 2c82b3610d2f942ae483b360f7facb7da15ad5ed Mon Sep 17 00:00:00 2001 From: Moxie Marlinspike Date: Mon, 2 Apr 2018 06:27:50 -0700 Subject: [PATCH] Mark DB current after backup upgrade process Fixes #7596 --- src/org/thoughtcrime/securesms/database/DatabaseFactory.java | 1 + .../securesms/database/helpers/SQLCipherOpenHelper.java | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/org/thoughtcrime/securesms/database/DatabaseFactory.java b/src/org/thoughtcrime/securesms/database/DatabaseFactory.java index dded639ec9..0c67c74b18 100644 --- a/src/org/thoughtcrime/securesms/database/DatabaseFactory.java +++ b/src/org/thoughtcrime/securesms/database/DatabaseFactory.java @@ -136,6 +136,7 @@ public class DatabaseFactory { public static void upgradeRestored(Context context, SQLiteDatabase database){ getInstance(context).databaseHelper.onUpgrade(database, database.getVersion(), -1); + getInstance(context).databaseHelper.markCurrent(database); } private DatabaseFactory(@NonNull Context context) { diff --git a/src/org/thoughtcrime/securesms/database/helpers/SQLCipherOpenHelper.java b/src/org/thoughtcrime/securesms/database/helpers/SQLCipherOpenHelper.java index b9d4303d8c..b6bb188045 100644 --- a/src/org/thoughtcrime/securesms/database/helpers/SQLCipherOpenHelper.java +++ b/src/org/thoughtcrime/securesms/database/helpers/SQLCipherOpenHelper.java @@ -185,6 +185,10 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper { return getWritableDatabase(databaseSecret.asString()); } + public void markCurrent(SQLiteDatabase db) { + db.setVersion(DATABASE_VERSION); + } + private void executeStatements(SQLiteDatabase db, String[] statements) { for (String statement : statements) db.execSQL(statement);