From 0731f45d487ac6c7cc9d8f62f0e564378f2c8bb5 Mon Sep 17 00:00:00 2001 From: Friedel Ziegelmayer Date: Fri, 16 Sep 2016 18:26:15 +0200 Subject: [PATCH 1/3] fix(get): properly handled nested content --- src/tar-stream-to-objects.js | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/tar-stream-to-objects.js b/src/tar-stream-to-objects.js index b817d5612..9630c72f2 100644 --- a/src/tar-stream-to-objects.js +++ b/src/tar-stream-to-objects.js @@ -5,28 +5,36 @@ const Readable = require('readable-stream') // transform tar stream into readable stream of // { path: 'string', content: Readable } -module.exports = function (err, res, send, done) { +module.exports = (err, res, send, done) => { if (err) { return done(err) } - var ex = tar.extract() + const ex = tar.extract() res.pipe(ex) - var objStream = new Readable({ objectMode: true }) + const objStream = new Readable({ objectMode: true }) objStream._read = function noop () {} - ex.on('entry', function (header, stream, next) { - objStream.push({ - path: header.name, - content: header.type !== 'directory' ? stream : null - }) - next() + ex.on('entry', (header, stream, next) => { + stream.on('end', next) + + if (header.type !== 'directory') { + objStream.push({ + path: header.name, + content: stream + }) + } else { + objStream.push({ + path: header.name + }) + stream.resume() + } }) + ex.on('finish', () => { objStream.push(null) }) done(null, objStream) } - From e6dcedac2535bf1a7ccb4c2ba4789410c1761411 Mon Sep 17 00:00:00 2001 From: Friedel Ziegelmayer Date: Tue, 8 Nov 2016 14:03:24 +0100 Subject: [PATCH 2/3] cleanup --- src/tar-stream-to-objects.js | 42 +++++++++++++++++------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/src/tar-stream-to-objects.js b/src/tar-stream-to-objects.js index 9630c72f2..acab14658 100644 --- a/src/tar-stream-to-objects.js +++ b/src/tar-stream-to-objects.js @@ -10,31 +10,29 @@ module.exports = (err, res, send, done) => { return done(err) } - const ex = tar.extract() - res.pipe(ex) - const objStream = new Readable({ objectMode: true }) objStream._read = function noop () {} - ex.on('entry', (header, stream, next) => { - stream.on('end', next) - - if (header.type !== 'directory') { - objStream.push({ - path: header.name, - content: stream - }) - } else { - objStream.push({ - path: header.name - }) - stream.resume() - } - }) - - ex.on('finish', () => { - objStream.push(null) - }) + res + .pipe(tar.extract()) + .on('entry', (header, stream, next) => { + stream.on('end', next) + + if (header.type !== 'directory') { + objStream.push({ + path: header.name, + content: stream + }) + } else { + objStream.push({ + path: header.name + }) + stream.resume() + } + }) + .on('finish', () => { + objStream.push(null) + }) done(null, objStream) } From 1191bb63a39408033976088c5ab079e466f94ab7 Mon Sep 17 00:00:00 2001 From: David Dias Date: Tue, 8 Nov 2016 13:10:13 +0000 Subject: [PATCH 3/3] feat: update interface-ipfs-core --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index cd2cb1c2e..f74767aea 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "chai": "^3.5.0", "gulp": "^3.9.1", "hapi": "^15.2.0", - "interface-ipfs-core": "^0.18.0", + "interface-ipfs-core": "^0.18.2", "ipfsd-ctl": "^0.17.0", "pre-commit": "^1.1.3", "socket.io": "^1.5.1",