Remove storageIds on rows that have no other identifier.

This commit is contained in:
Greyson Parrelli 2021-04-26 15:32:43 -04:00 committed by Cody Henthorne
parent 4aec824bfd
commit 006eebb09e

View file

@ -173,8 +173,9 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper implements SignalDatab
private static final int CLEAN_STORAGE_IDS = 92;
private static final int MP4_GIF_SUPPORT = 93;
private static final int BLUR_AVATARS = 94;
private static final int CLEAN_STORAGE_IDS_WITHOUT_INFO = 95;
private static final int DATABASE_VERSION = 94;
private static final int DATABASE_VERSION = 95;
private static final String DATABASE_NAME = "signal.db";
private final Context context;
@ -1322,6 +1323,13 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper implements SignalDatab
db.rawExecSQL("UPDATE recipient SET groups_in_common = 1 WHERE _id IN (" + selectIdsWithGroupsInCommon + ")");
}
if (oldVersion < CLEAN_STORAGE_IDS_WITHOUT_INFO) {
ContentValues values = new ContentValues();
values.putNull("storage_service_key");
int count = db.update("recipient", values, "storage_service_key NOT NULL AND phone IS NULL AND uuid IS NULL AND group_id IS NULL", null);
Log.i(TAG, "There were " + count + " bad rows that had their storageID removed due to not having any other identifier.");
}
db.setTransactionSuccessful();
} finally {
db.endTransaction();