mirror of https://github.com/zlatinb/muwire
write to memmapped file in 8kb increments
parent
85ad3109f9
commit
9b6a2fd952
|
@ -183,15 +183,14 @@ class DownloadSession {
|
||||||
mapped.position(position)
|
mapped.position(position)
|
||||||
|
|
||||||
byte[] tmp = new byte[0x1 << 13]
|
byte[] tmp = new byte[0x1 << 13]
|
||||||
|
DataInputStream dis = new DataInputStream(is)
|
||||||
while(mapped.hasRemaining()) {
|
while(mapped.hasRemaining()) {
|
||||||
if (mapped.remaining() < tmp.length)
|
if (mapped.remaining() < tmp.length)
|
||||||
tmp = new byte[mapped.remaining()]
|
tmp = new byte[mapped.remaining()]
|
||||||
int read = is.read(tmp)
|
dis.readFully(tmp)
|
||||||
if (read == -1)
|
|
||||||
throw new IOException()
|
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
mapped.put(tmp, 0, read)
|
mapped.put(tmp)
|
||||||
dataSinceLastRead.addAndGet(read)
|
dataSinceLastRead.addAndGet(tmp.length)
|
||||||
pieces.markPartial(piece, mapped.position())
|
pieces.markPartial(piece, mapped.position())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue