Revert "Don't recreate attachment InputStream if we don't have to."

This reverts commit 467dae8132.
This commit is contained in:
Nicholas Tinsley
2024-02-05 10:49:05 -05:00
parent adf1d8a43a
commit f18070b78c
3 changed files with 15 additions and 179 deletions
@@ -5,9 +5,9 @@
package org.signal.core.util
import java.io.EOFException
import java.io.IOException
import java.io.InputStream
import kotlin.jvm.Throws
/**
* Reads a 32-bit variable-length integer from the stream.
@@ -80,26 +80,3 @@ fun InputStream.readLength(): Long {
return count
}
/**
* Backported from AOSP API 31 source code.
*
* @param count number of bytes to skip
*/
@Throws(IOException::class)
fun InputStream.skipNBytesCompat(count: Long) {
var n = count
while (n > 0) {
val ns = skip(n)
if (ns in 1..n) {
n -= ns
} else if (ns == 0L) {
if (read() == -1) {
throw EOFException()
}
n--
} else {
throw IOException("Unable to skip exactly")
}
}
}