Skip to content

Commit

Permalink
Cleanup abandoned mentions during backup restore.
Browse files Browse the repository at this point in the history
  • Loading branch information
cody-signal committed Oct 8, 2020
1 parent 1d230d4 commit 8d06083
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ void deleteMentionsForMessage(long messageId) {

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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,8 @@ void trimEntriesForExpiredMessages() {
}
}

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);
Expand Down

0 comments on commit 8d06083

Please sign in to comment.