mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 13:08:46 +00:00
Fix crash when downloading attachment from S3.
This commit is contained in:
committed by
Cody Henthorne
parent
36a8a399d9
commit
7735ca9dab
@@ -981,9 +981,10 @@ class AttachmentTable(
|
||||
limitStream.leftoverStream().allMatch { it == 0x00.toByte() }
|
||||
}
|
||||
|
||||
val digest = if (paddingAllZeroes) {
|
||||
// Existing digest may be null for non-user attachments, like things pulled from S3
|
||||
val digest = if (existingPlaceholder.remoteDigest != null && paddingAllZeroes) {
|
||||
Log.d(TAG, "[finalizeAttachmentAfterDownload] $attachmentId has all-zero padding. Digest is good.")
|
||||
existingPlaceholder.remoteDigest!!
|
||||
existingPlaceholder.remoteDigest
|
||||
} else {
|
||||
Log.w(TAG, "[finalizeAttachmentAfterDownload] $attachmentId has non-zero padding bytes. Recomputing digest.")
|
||||
|
||||
|
||||
@@ -416,11 +416,15 @@ class AttachmentDownloadJob private constructor(
|
||||
if (body.contentLength() > RemoteConfig.maxAttachmentReceiveSizeBytes) {
|
||||
throw MmsException("Attachment too large, failing download")
|
||||
}
|
||||
|
||||
SignalDatabase.attachments.createKeyIvIfNecessary(attachmentId)
|
||||
val updatedAttachment = SignalDatabase.attachments.getAttachment(attachmentId)!!
|
||||
|
||||
SignalDatabase.attachments.finalizeAttachmentAfterDownload(
|
||||
messageId,
|
||||
attachmentId,
|
||||
LimitedInputStream.withoutLimits((body.source() as Source).buffer().inputStream()),
|
||||
iv = null
|
||||
iv = updatedAttachment.remoteIv
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user