From 5e0ede9f18849519c1fbf0076a5ed2d595d38599 Mon Sep 17 00:00:00 2001 From: David Dias Date: Wed, 24 Aug 2016 16:27:24 +0100 Subject: [PATCH] fix(block): cope with the fact that sometimes go-ipfs sends x-stream, other times it doesn't --- src/api/block.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/api/block.js b/src/api/block.js index 20a6968fd..e7458c023 100644 --- a/src/api/block.js +++ b/src/api/block.js @@ -19,12 +19,16 @@ module.exports = (send) => { if (err) { return callback(err) } - res.pipe(bl((err, data) => { - if (err) { - return callback(err) - } - callback(null, new Block(data)) - })) + if (Buffer.isBuffer(res)) { + callback(null, new Block(res)) + } else { + res.pipe(bl((err, data) => { + if (err) { + return callback(err) + } + callback(null, new Block(data)) + })) + } }) }), stat: promisify((args, opts, callback) => {