fix(writer): Emit checksum event when verifying bmaps (#1859)

Due to the Blockmap.FilterStream not emitting a "checksum"
event (as it individually verifies specified ranges), the
flashing process would get stuck on finish.

This emits a "checksum" event on "finish" when blockmapping,
averting this issue.

Change-Type: patch
This commit is contained in:
Jonas Hermsmeier 2017-11-17 22:56:25 +01:00 committed by GitHub
parent b3b52fce62
commit 6779e15872
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -272,7 +272,15 @@ class ImageWriter extends EventEmitter {
if (options.image.bmap) {
debug('verify:bmap')
const blockMap = BlockMap.parse(options.image.bmap)
pipeline.append(new BlockMap.FilterStream(blockMap))
const blockMapStream = new BlockMap.FilterStream(blockMap)
pipeline.append(blockMapStream)
// NOTE: Because the blockMapStream checksums each range,
// and doesn't emit a final "checksum" event, we artificially
// raise one once the stream finishes
blockMapStream.once('finish', () => {
pipeline.emit('checksum', {})
})
} else {
const checksumStream = new ChecksumStream({
algorithms: options.checksumAlgorithms