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'
|
||||
|
||||
const assert = require('assert')
|
||||
const { pipeline, Transform } = require('readable-stream')
|
||||
const { readChunk } = require('@vates/read-chunk')
|
||||
const { readChunkStrict } = require('@vates/read-chunk')
|
||||
|
||||
const checkFooter = require('./checkFooter')
|
||||
const checkHeader = require('./_checkHeader')
|
||||
@@ -42,9 +41,8 @@ module.exports = async function createVhdStreamWithLength(stream) {
|
||||
let streamPosition = 0
|
||||
|
||||
async function readStream(length) {
|
||||
const chunk = await readChunk(stream, length)
|
||||
assert.strictEqual(chunk.length, length)
|
||||
streamPosition += chunk.length
|
||||
const chunk = await readChunkStrict(stream, length)
|
||||
streamPosition += length
|
||||
readBuffers.push(chunk)
|
||||
return chunk
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user