From a84a7457c1e4f916b097127ed002c45a875e0aa6 Mon Sep 17 00:00:00 2001 From: Volker Mische Date: Wed, 9 Jan 2019 14:40:34 +0100 Subject: [PATCH] Revert "chore: remove the conditional" This reverts commit 01098074ddaf564250d33dde89703b7c9dfc0ece. Fixes https://github.com/ipfs/js-ipfs/issues/1810. --- src/builder/builder.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/builder/builder.js b/src/builder/builder.js index 237031a..f4f9ade 100644 --- a/src/builder/builder.js +++ b/src/builder/builder.js @@ -24,8 +24,7 @@ const defaultOptions = { rawLeaves: false, hashAlg: 'sha2-256', leafType: 'file', - cidVersion: 0, - progress: () => {} + cidVersion: 0 } module.exports = function builder (createChunker, ipld, createReducer, _options) { @@ -107,8 +106,10 @@ module.exports = function builder (createChunker, ipld, createReducer, _options) pull( file.content, chunker, - through(buffer => { - options.progress(buffer.length) + through(chunk => { + if (options.progress && typeof options.progress === 'function') { + options.progress(chunk.byteLength) + } }), paraMap((buffer, callback) => { waterfall([