🐛 Close file stream if end has been reached
This commit is contained in:
parent
03128a2920
commit
79412cefa0
1 changed files with 3 additions and 2 deletions
|
@ -33,12 +33,13 @@ export default async function getFileFromDisks(disks: string[], { diskStart, off
|
|||
//We can still write the whole chunk before ending the stream
|
||||
if (readTooManyBytes === 0) {
|
||||
outputStream.end(chunk);
|
||||
curDisk.close();
|
||||
} else {
|
||||
//We must shorten the chunk, write the shortened chunk and then end the stream
|
||||
const shortenedLength = chunk.length - readTooManyBytes;
|
||||
const shortenedChunk = new Buffer(shortenedLength);
|
||||
shortenedChunk.fill(chunk, 0, shortenedLength);
|
||||
const shortenedChunk = Buffer.alloc(shortenedLength, chunk);
|
||||
outputStream.end(shortenedChunk);
|
||||
curDisk.close();
|
||||
}
|
||||
} else {
|
||||
//Nowhere near the end, so just write normally
|
||||
|
|
Loading…
Reference in a new issue