Gotta love int overflows in Java
This commit is contained in:
1 parent
622cc51e96
commit
9eb621efd7
2 files changed
+3
-5
No files matched your search
@@ -20,7 +20,7 @@ private const val TAG = "BlockDeviceInputStream"
|
||||
class BlockDeviceInputStream(
|
||||
private val blockDev: BlockDeviceDriver,
|
||||
private val coroutineScope: CoroutineScope,
|
||||
private val bufferBlocks: Int = 512,
|
||||
private val bufferBlocks: Long = 512,
|
||||
private val prefetchBuffers: Int = 4,
|
||||
) : AsyncInputStream(), ISeekableStream {
|
||||
private lateinit var mReadBuffer: ByteBuffer
|
||||
|
||||
@@ -4,7 +4,6 @@ import android.util.Log
|
||||
import eu.depau.etchdroid.utils.AsyncOutputStream
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.channels.ClosedReceiveChannelException
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -34,7 +33,7 @@ interface ISeekableStream {
|
||||
class BlockDeviceOutputStream(
|
||||
private val blockDev: BlockDeviceDriver,
|
||||
private val coroutineScope: CoroutineScope,
|
||||
private val bufferBlocks: Int = 512,
|
||||
private val bufferBlocks: Long = 512,
|
||||
private val queueSize: Int = 4,
|
||||
) : AsyncOutputStream(), ISeekableStream {
|
||||
|
||||
@@ -46,7 +45,7 @@ class BlockDeviceOutputStream(
|
||||
private val mSizeBytes: Long
|
||||
get() = blockDev.blocks * blockDev.blockSize
|
||||
|
||||
private var mByteBuffer = ByteBuffer.allocate(minOf(blockDev.blockSize * bufferBlocks, mSizeBytes.toInt()))
|
||||
private var mByteBuffer = ByteBuffer.allocate(minOf(blockDev.blockSize * bufferBlocks, mSizeBytes).toInt())
|
||||
|
||||
private val isEOF: Boolean
|
||||
get() = mCurrentOffset >= mSizeBytes
|
||||
@@ -157,7 +156,6 @@ class BlockDeviceOutputStream(
|
||||
}
|
||||
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
override suspend fun flushAsync() {
|
||||
commit()
|
||||
ensureIoThread()
|
||||
|
||||
Reference in new issue
Block a user