From 6779e15872b8fe9d693cb2adbda828eb32fe8fe5 Mon Sep 17 00:00:00 2001 From: Jonas Hermsmeier Date: Fri, 17 Nov 2017 22:56:25 +0100 Subject: [PATCH] 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 --- lib/writer/index.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/writer/index.js b/lib/writer/index.js index 9f7680e2..26f2200f 100644 --- a/lib/writer/index.js +++ b/lib/writer/index.js @@ -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