Cleanup some possible bad RecipientIds in the MMS table.
This commit is contained in:
parent
daeb823399
commit
4b3d129097
2 changed files with 18 additions and 3 deletions
|
@ -85,8 +85,9 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
|
|||
private static final int ATTACHMENT_HASHING = 28;
|
||||
private static final int NOTIFICATION_RECIPIENT_IDS = 29;
|
||||
private static final int BLUR_HASH = 30;
|
||||
private static final int MMS_RECIPIENT_CLEANUP_2 = 31;
|
||||
|
||||
private static final int DATABASE_VERSION = 30;
|
||||
private static final int DATABASE_VERSION = 31;
|
||||
private static final String DATABASE_NAME = "signal.db";
|
||||
|
||||
private final Context context;
|
||||
|
@ -589,6 +590,13 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
|
|||
db.execSQL("ALTER TABLE part ADD COLUMN blur_hash TEXT DEFAULT NULL");
|
||||
}
|
||||
|
||||
if (oldVersion < MMS_RECIPIENT_CLEANUP_2) {
|
||||
ContentValues values = new ContentValues(1);
|
||||
values.put("address", "-1");
|
||||
int count = db.update("mms", values, "address = ? OR address IS NULL", new String[] { "0" });
|
||||
Log.i(TAG, "MMS recipient cleanup 2 updated " + count + " rows.");
|
||||
}
|
||||
|
||||
db.setTransactionSuccessful();
|
||||
} finally {
|
||||
db.endTransaction();
|
||||
|
|
|
@ -24,14 +24,18 @@ public class RecipientId implements Parcelable, Comparable<RecipientId> {
|
|||
|
||||
public static RecipientId from(long id) {
|
||||
if (id == 0) {
|
||||
throw new AssertionError("Invalid ID!");
|
||||
throw new InvalidLongRecipientIdError();
|
||||
}
|
||||
|
||||
return new RecipientId(id);
|
||||
}
|
||||
|
||||
public static RecipientId from(@NonNull String id) {
|
||||
return RecipientId.from(Long.parseLong(id));
|
||||
try {
|
||||
return RecipientId.from(Long.parseLong(id));
|
||||
} catch (NumberFormatException e) {
|
||||
throw new InvalidStringRecipientIdError();
|
||||
}
|
||||
}
|
||||
|
||||
private RecipientId(long id) {
|
||||
|
@ -116,4 +120,7 @@ public class RecipientId implements Parcelable, Comparable<RecipientId> {
|
|||
return new RecipientId[size];
|
||||
}
|
||||
};
|
||||
|
||||
private static class InvalidLongRecipientIdError extends AssertionError {}
|
||||
private static class InvalidStringRecipientIdError extends AssertionError {}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue