Fix issue with re-using forwarded attachment pointers.

We were deleting upload data for incoming attachments when we shouldn't
have.

Fixes #9570
This commit is contained in:
Greyson Parrelli 2020-04-30 14:04:53 -04:00
parent c9f2f57427
commit 9d35fb397b
2 changed files with 7 additions and 8 deletions

View File

@ -535,14 +535,10 @@ public class AttachmentDatabase extends Database {
} }
values.put(TRANSFER_STATE, TRANSFER_PROGRESS_DONE); values.put(TRANSFER_STATE, TRANSFER_PROGRESS_DONE);
values.put(CDN_NUMBER, 0);
values.put(CONTENT_LOCATION, (String)null);
values.put(CONTENT_DISPOSITION, (String)null);
values.put(DIGEST, (byte[])null);
values.put(NAME, (String) null);
values.put(FAST_PREFLIGHT_ID, (String)null);
values.put(TRANSFER_FILE, (String)null); values.put(TRANSFER_FILE, (String)null);
values.put(TRANSFORM_PROPERTIES, TransformProperties.forSkipTransform().serialize());
if (database.update(TABLE_NAME, values, PART_ID_WHERE, attachmentId.toStrings()) == 0) { if (database.update(TABLE_NAME, values, PART_ID_WHERE, attachmentId.toStrings()) == 0) {
//noinspection ResultOfMethodCallIgnored //noinspection ResultOfMethodCallIgnored
dataInfo.file.delete(); dataInfo.file.delete();
@ -1198,7 +1194,9 @@ public class AttachmentDatabase extends Database {
} }
} }
boolean useTemplateUpload = template.getUploadTimestamp() > attachment.getUploadTimestamp() && template.getTransferState() == TRANSFER_PROGRESS_DONE; boolean useTemplateUpload = template.getUploadTimestamp() > attachment.getUploadTimestamp() &&
template.getTransferState() == TRANSFER_PROGRESS_DONE &&
template.getTransformProperties().shouldSkipTransform();
ContentValues contentValues = new ContentValues(); ContentValues contentValues = new ContentValues();
contentValues.put(MMS_ID, mmsId); contentValues.put(MMS_ID, mmsId);

View File

@ -4,6 +4,7 @@ import android.graphics.Bitmap;
import android.media.MediaDataSource; import android.media.MediaDataSource;
import android.media.MediaMetadataRetriever; import android.media.MediaMetadataRetriever;
import android.os.Build; import android.os.Build;
import android.text.TextUtils;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
@ -114,7 +115,7 @@ public final class AttachmentUploadJob extends BaseJob {
} }
long timeSinceUpload = System.currentTimeMillis() - databaseAttachment.getUploadTimestamp(); long timeSinceUpload = System.currentTimeMillis() - databaseAttachment.getUploadTimestamp();
if (timeSinceUpload < UPLOAD_REUSE_THRESHOLD) { if (timeSinceUpload < UPLOAD_REUSE_THRESHOLD && !TextUtils.isEmpty(databaseAttachment.getLocation())) {
Log.i(TAG, "We can re-use an already-uploaded file. It was uploaded " + timeSinceUpload + " ms ago. Skipping."); Log.i(TAG, "We can re-use an already-uploaded file. It was uploaded " + timeSinceUpload + " ms ago. Skipping.");
return; return;
} else if (databaseAttachment.getUploadTimestamp() > 0) { } else if (databaseAttachment.getUploadTimestamp() > 0) {