File tree Expand file tree Collapse file tree
app/src/main/java/org/thoughtcrime/securesms Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -981,9 +981,10 @@ class AttachmentTable(
981981 limitStream.leftoverStream().allMatch { it == 0x00 .toByte() }
982982 }
983983
984- val digest = if (paddingAllZeroes) {
984+ // Existing digest may be null for non-user attachments, like things pulled from S3
985+ val digest = if (existingPlaceholder.remoteDigest != null && paddingAllZeroes) {
985986 Log .d(TAG , " [finalizeAttachmentAfterDownload] $attachmentId has all-zero padding. Digest is good." )
986- existingPlaceholder.remoteDigest!!
987+ existingPlaceholder.remoteDigest
987988 } else {
988989 Log .w(TAG , " [finalizeAttachmentAfterDownload] $attachmentId has non-zero padding bytes. Recomputing digest." )
989990
Original file line number Diff line number Diff line change @@ -416,11 +416,15 @@ class AttachmentDownloadJob private constructor(
416416 if (body.contentLength() > RemoteConfig .maxAttachmentReceiveSizeBytes) {
417417 throw MmsException (" Attachment too large, failing download" )
418418 }
419+
420+ SignalDatabase .attachments.createKeyIvIfNecessary(attachmentId)
421+ val updatedAttachment = SignalDatabase .attachments.getAttachment(attachmentId)!!
422+
419423 SignalDatabase .attachments.finalizeAttachmentAfterDownload(
420424 messageId,
421425 attachmentId,
422426 LimitedInputStream .withoutLimits((body.source() as Source ).buffer().inputStream()),
423- iv = null
427+ iv = updatedAttachment.remoteIv
424428 )
425429 }
426430 }
You can’t perform that action at this time.
0 commit comments