Cleanup abandoned mentions during backup restore.

master
Cody Henthorne 2020-10-08 09:46:26 -04:00 committed by GitHub
parent 1d230d4cd6
commit 8d060837ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View File

@ -134,7 +134,7 @@ public class MentionDatabase extends Database {
void deleteAbandonedMentions() {
SQLiteDatabase db = databaseHelper.getWritableDatabase();
String where = MESSAGE_ID + " NOT IN (SELECT _id FROM " + MmsDatabase.TABLE_NAME + ") OR " + THREAD_ID + " NOT IN (SELECT _id FROM " + ThreadDatabase.TABLE_NAME + ")";
String where = MESSAGE_ID + " NOT IN (SELECT " + MmsDatabase.ID + " FROM " + MmsDatabase.TABLE_NAME + ") OR " + THREAD_ID + " NOT IN (SELECT " + ThreadDatabase.ID + " FROM " + ThreadDatabase.TABLE_NAME + ")";
db.delete(TABLE_NAME, where, null);
}

View File

@ -935,6 +935,8 @@ public class MmsDatabase extends MessageDatabase {
}
}
DatabaseFactory.getMentionDatabase(context).deleteAbandonedMentions();
try (Cursor cursor = database.query(ThreadDatabase.TABLE_NAME, new String[] { ThreadDatabase.ID }, ThreadDatabase.EXPIRES_IN + " > 0", null, null, null, null)) {
while (cursor != null && cursor.moveToNext()) {
DatabaseFactory.getThreadDatabase(context).update(cursor.getLong(0), false);