mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 12:05:22 +00:00
Fix backup restore issues from restoring newer Signal backups.
Fixes #8184
This commit is contained in:
parent
15b4517e35
commit
ad036b0d6a
@ -241,11 +241,13 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
|
||||
}
|
||||
}
|
||||
|
||||
if (oldVersion < QUOTE_MISSING) {
|
||||
// Note: This column only being checked due to upgrade issues as described in #8184
|
||||
if (oldVersion < QUOTE_MISSING && !columnExists(db, "mms", "quote_missing")) {
|
||||
db.execSQL("ALTER TABLE mms ADD COLUMN quote_missing INTEGER DEFAULT 0");
|
||||
}
|
||||
|
||||
if (oldVersion < NOTIFICATION_CHANNELS) {
|
||||
// Note: The column only being checked due to upgrade issues as described in #8184
|
||||
if (oldVersion < NOTIFICATION_CHANNELS && !columnExists(db, "recipient_preferences", "notification_channel")) {
|
||||
db.execSQL("ALTER TABLE recipient_preferences ADD COLUMN notification_channel TEXT DEFAULT NULL");
|
||||
NotificationChannels.create(context);
|
||||
|
||||
@ -309,5 +311,19 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
|
||||
db.execSQL(statement);
|
||||
}
|
||||
|
||||
private static boolean columnExists(@NonNull SQLiteDatabase db, @NonNull String table, @NonNull String column) {
|
||||
try (Cursor cursor = db.rawQuery("PRAGMA table_info(" + table + ")", null)) {
|
||||
int nameColumnIndex = cursor.getColumnIndexOrThrow("name");
|
||||
|
||||
while (cursor.moveToNext()) {
|
||||
String name = cursor.getString(nameColumnIndex);
|
||||
|
||||
if (name.equals(column)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user