Fix extraneous incremental chunk sizes.

This commit is contained in:
Michelle Tang
2024-11-08 11:02:28 -05:00
committed by Greyson Parrelli
parent ed24fd0c4b
commit ea38376c3a
4 changed files with 56 additions and 11 deletions

View File

@@ -63,7 +63,7 @@ class DigestingRequestBody(
outputStream.flush()
val incrementalDigest: ByteArray = if (isIncremental) {
val incrementalDigest: ByteArray? = if (isIncremental) {
if (contentLength != outputStream.totalBytesWritten) {
Log.w(TAG, "Content uploaded ${logMessage(outputStream.totalBytesWritten, contentLength)} bytes compared to expected!")
} else {
@@ -73,10 +73,12 @@ class DigestingRequestBody(
digestStream.close()
digestStream.toByteArray()
} else {
ByteArray(0)
null
}
attachmentDigest = AttachmentDigest(outputStream.transmittedDigest, incrementalDigest, sizeChoice.sizeInBytes)
val incrementalDigestChunkSize: Int = if (incrementalDigest?.isNotEmpty() == true) sizeChoice.sizeInBytes else 0
attachmentDigest = AttachmentDigest(outputStream.transmittedDigest, incrementalDigest, incrementalDigestChunkSize)
}
override fun contentLength(): Long {