Fix possible de-duping issues.
- Clean bad hashes from earlier release. - Fix file equality comparison. - Given our new de-duping, we don't want to run into a situation where two simultaneous compressions could be happening on the same image.
This commit is contained in:
parent
23d478191f
commit
4260a8436b
3 changed files with 10 additions and 3 deletions
|
@ -819,7 +819,7 @@ public class AttachmentDatabase extends Database {
|
|||
Optional<DataInfo> sharedDataInfo = findDuplicateDataFileInfo(database, hash, attachmentId);
|
||||
if (sharedDataInfo.isPresent()) {
|
||||
Log.i(TAG, "[setAttachmentData] Duplicate data file found! " + sharedDataInfo.get().file.getAbsolutePath());
|
||||
if (sharedDataInfo.get().file != destination && destination.delete()) {
|
||||
if (!destination.equals(sharedDataInfo.get().file) && destination.delete()) {
|
||||
Log.i(TAG, "[setAttachmentData] Deleted original file. " + destination);
|
||||
}
|
||||
return sharedDataInfo.get();
|
||||
|
|
|
@ -87,8 +87,9 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
|
|||
private static final int BLUR_HASH = 30;
|
||||
private static final int MMS_RECIPIENT_CLEANUP_2 = 31;
|
||||
private static final int ATTACHMENT_TRANSFORM_PROPERTIES = 32;
|
||||
private static final int ATTACHMENT_CLEAR_HASHES = 33;
|
||||
|
||||
private static final int DATABASE_VERSION = 32;
|
||||
private static final int DATABASE_VERSION = 33;
|
||||
private static final String DATABASE_NAME = "signal.db";
|
||||
|
||||
private final Context context;
|
||||
|
@ -602,6 +603,10 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
|
|||
db.execSQL("ALTER TABLE part ADD COLUMN transform_properties TEXT DEFAULT NULL");
|
||||
}
|
||||
|
||||
if (oldVersion < ATTACHMENT_CLEAR_HASHES) {
|
||||
db.execSQL("UPDATE part SET data_hash = null");
|
||||
}
|
||||
|
||||
db.setTransactionSuccessful();
|
||||
} finally {
|
||||
db.endTransaction();
|
||||
|
|
|
@ -74,7 +74,7 @@ public final class AttachmentCompressionJob extends BaseJob {
|
|||
.addConstraint(NetworkConstraint.KEY)
|
||||
.setLifespan(TimeUnit.DAYS.toMillis(1))
|
||||
.setMaxAttempts(Parameters.UNLIMITED)
|
||||
.setQueue(isVideoTranscode ? "VIDEO_TRANSCODE" : null)
|
||||
.setQueue(isVideoTranscode ? "VIDEO_TRANSCODE" : "GENERIC_TRANSCODE")
|
||||
.build(),
|
||||
attachmentId,
|
||||
mms,
|
||||
|
@ -108,6 +108,8 @@ public final class AttachmentCompressionJob extends BaseJob {
|
|||
|
||||
@Override
|
||||
public void onRun() throws Exception {
|
||||
Log.d(TAG, "Running for: " + attachmentId);
|
||||
|
||||
AttachmentDatabase database = DatabaseFactory.getAttachmentDatabase(context);
|
||||
DatabaseAttachment databaseAttachment = database.getAttachment(attachmentId);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue