Store file hash to avoid data duplication.

This commit is contained in:
alex-signal
2019-09-26 17:29:38 -03:00
committed by Greyson Parrelli
parent 8449d75684
commit 7d02bb8487
2 changed files with 193 additions and 42 deletions

View File

@@ -76,8 +76,9 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
private static final int RECIPIENT_SEARCH = 25;
private static final int RECIPIENT_CLEANUP = 26;
private static final int MMS_RECIPIENT_CLEANUP = 27;
private static final int ATTACHMENT_HASHING = 28;
private static final int DATABASE_VERSION = 27;
private static final int DATABASE_VERSION = 28;
private static final String DATABASE_NAME = "signal.db";
private final Context context;
@@ -522,6 +523,11 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
Log.i(TAG, "MMS recipient cleanup updated " + count + " rows.");
}
if (oldVersion < ATTACHMENT_HASHING) {
db.execSQL("ALTER TABLE part ADD COLUMN data_hash TEXT DEFAULT NULL");
db.execSQL("CREATE INDEX IF NOT EXISTS part_data_hash_index ON part (data_hash)");
}
db.setTransactionSuccessful();
} finally {
db.endTransaction();