Fix possible IllegalArgumentException during a database migration.

pull/1/head
Greyson Parrelli 6 years ago
parent 94e8553b73
commit b962751c96

@ -387,15 +387,17 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
if (oldVersion < SELF_ATTACHMENT_CLEANUP) { if (oldVersion < SELF_ATTACHMENT_CLEANUP) {
String localNumber = TextSecurePreferences.getLocalNumber(context); String localNumber = TextSecurePreferences.getLocalNumber(context);
try (Cursor threadCursor = db.rawQuery("SELECT _id FROM thread WHERE recipient_ids = ?", new String[]{ localNumber })) { if (!TextUtils.isEmpty(localNumber)) {
if (threadCursor != null && threadCursor.moveToFirst()) { try (Cursor threadCursor = db.rawQuery("SELECT _id FROM thread WHERE recipient_ids = ?", new String[]{ localNumber })) {
long threadId = threadCursor.getLong(0); if (threadCursor != null && threadCursor.moveToFirst()) {
ContentValues updateValues = new ContentValues(1); long threadId = threadCursor.getLong(0);
ContentValues updateValues = new ContentValues(1);
updateValues.put("pending_push", 0); updateValues.put("pending_push", 0);
int count = db.update("part", updateValues, "mid IN (SELECT _id FROM mms WHERE thread_id = ?)", new String[]{ String.valueOf(threadId) }); int count = db.update("part", updateValues, "mid IN (SELECT _id FROM mms WHERE thread_id = ?)", new String[]{ String.valueOf(threadId) });
Log.i(TAG, "Updated " + count + " self-sent attachments."); Log.i(TAG, "Updated " + count + " self-sent attachments.");
}
} }
} }
} }

Loading…
Cancel
Save