chore(vhd-lib/createVhdStreamWithLength): use readChunkStrict
Related to zammad#10996 Not only it simplified the code a bit, but it also provides better error messages, especially on stream end.
This commit is contained in:
@@ -1,8 +1,7 @@
|
|||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const assert = require('assert')
|
|
||||||
const { pipeline, Transform } = require('readable-stream')
|
const { pipeline, Transform } = require('readable-stream')
|
||||||
const { readChunk } = require('@vates/read-chunk')
|
const { readChunkStrict } = require('@vates/read-chunk')
|
||||||
|
|
||||||
const checkFooter = require('./checkFooter')
|
const checkFooter = require('./checkFooter')
|
||||||
const checkHeader = require('./_checkHeader')
|
const checkHeader = require('./_checkHeader')
|
||||||
@@ -42,9 +41,8 @@ module.exports = async function createVhdStreamWithLength(stream) {
|
|||||||
let streamPosition = 0
|
let streamPosition = 0
|
||||||
|
|
||||||
async function readStream(length) {
|
async function readStream(length) {
|
||||||
const chunk = await readChunk(stream, length)
|
const chunk = await readChunkStrict(stream, length)
|
||||||
assert.strictEqual(chunk.length, length)
|
streamPosition += length
|
||||||
streamPosition += chunk.length
|
|
||||||
readBuffers.push(chunk)
|
readBuffers.push(chunk)
|
||||||
return chunk
|
return chunk
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user