mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-22 20:18:36 +00:00
Additional logging around incrementally digested uploads.
This commit is contained in:
committed by
Cody Henthorne
parent
afd3afcf0d
commit
e861204cb0
@@ -3,6 +3,7 @@ package org.whispersystems.signalservice.internal.push.http
|
|||||||
import okhttp3.MediaType
|
import okhttp3.MediaType
|
||||||
import okhttp3.RequestBody
|
import okhttp3.RequestBody
|
||||||
import okio.BufferedSink
|
import okio.BufferedSink
|
||||||
|
import org.signal.libsignal.protocol.logging.Log
|
||||||
import org.whispersystems.signalservice.api.crypto.DigestingOutputStream
|
import org.whispersystems.signalservice.api.crypto.DigestingOutputStream
|
||||||
import org.whispersystems.signalservice.api.crypto.SkippingOutputStream
|
import org.whispersystems.signalservice.api.crypto.SkippingOutputStream
|
||||||
import org.whispersystems.signalservice.api.messages.SignalServiceAttachment
|
import org.whispersystems.signalservice.api.messages.SignalServiceAttachment
|
||||||
@@ -62,7 +63,13 @@ class DigestingRequestBody(
|
|||||||
}
|
}
|
||||||
|
|
||||||
outputStream.flush()
|
outputStream.flush()
|
||||||
|
|
||||||
if (isIncremental) {
|
if (isIncremental) {
|
||||||
|
if (contentLength != total) {
|
||||||
|
Log.w(TAG, "Content uploaded ${logMessage(total, contentLength)} bytes compared to expected!")
|
||||||
|
} else {
|
||||||
|
Log.d(TAG, "Wrote the expected number of bytes.")
|
||||||
|
}
|
||||||
outputStream.close()
|
outputStream.close()
|
||||||
digestStream.close()
|
digestStream.close()
|
||||||
incrementalDigest = digestStream.toByteArray()
|
incrementalDigest = digestStream.toByteArray()
|
||||||
@@ -76,6 +83,15 @@ class DigestingRequestBody(
|
|||||||
|
|
||||||
fun getAttachmentDigest() = AttachmentDigest(transmittedDigest, incrementalDigest)
|
fun getAttachmentDigest() = AttachmentDigest(transmittedDigest, incrementalDigest)
|
||||||
|
|
||||||
|
private fun logMessage(actual: Long, expected: Long): String {
|
||||||
|
val difference = actual - expected
|
||||||
|
return if (difference > 0) {
|
||||||
|
"+$difference"
|
||||||
|
} else {
|
||||||
|
difference.toString()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val TAG = "DigestingRequestBody"
|
const val TAG = "DigestingRequestBody"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user