diff --git a/package.json b/package.json index 155d9174..d1fb53b9 100644 --- a/package.json +++ b/package.json @@ -40,8 +40,8 @@ "buffer-loader": "0.0.1", "chai": "^3.5.0", "fs-blob-store": "^5.2.1", - "idb-plus-blob-store": "^1.0.0", - "ipfs-repo": "^0.6.1", + "idb-plus-blob-store": "^1.1.1", + "ipfs-repo": "^0.6.6", "ncp": "^2.0.0", "pre-commit": "^1.1.2", "raw-loader": "^0.5.1", @@ -54,10 +54,10 @@ "block-stream2": "^1.1.0", "debug": "^2.2.0", "eventemitter2": "^1.0.0", - "ipfs-blocks": "^0.2.0", + "ipfs-blocks": "^0.2.1", "ipfs-merkle-dag": "^0.4.0", "ipfs-unixfs": "^0.1.0", - "readable-stream": "2.0.6", + "readable-stream": "^1.1.13", "through2": "^2.0.0" }, "contributors": [ diff --git a/src/importer.js b/src/importer.js index a22d06a5..ff58a0e1 100644 --- a/src/importer.js +++ b/src/importer.js @@ -41,7 +41,8 @@ function Importer (dagService, options) { n.data = d.marshal() dagService.add(n, (err) => { if (err) { - return this.emit('err', 'Failed to store' + fl.path) + this.emit('error', `Failed to store: ${fl.path}`) + return } const el = { path: fl.path, @@ -72,9 +73,10 @@ function Importer (dagService, options) { const l = new UnixFS('file', chunk) const n = new merkleDAG.DAGNode(l.marshal()) - dagService.add(n, function (err) { + dagService.add(n, (err) => { if (err) { - return this.emit('err', 'Failed to store chunk of' + fl.path) + this.emit('error', `Failed to store chunk of: ${fl.path}`) + return cb(err) } leaves.push({ @@ -118,7 +120,7 @@ function Importer (dagService, options) { n.data = f.marshal() dagService.add(n, (err) => { if (err) { - this.emit('err', 'Failed to store' + fl.path) + this.emit('error', `Failed to store: ${fl.path}`) return cb() } @@ -134,6 +136,7 @@ function Importer (dagService, options) { return done(cb) }) })) + function done (cb) { counter-- cb() @@ -242,7 +245,7 @@ function Importer (dagService, options) { n.data = d.marshal() dagService.add(n, (err) => { if (err) { - this.emit('err', 'failed to store dirNode') + this.emit('error', 'failed to store dirNode') } }) diff --git a/test/test-importer.js b/test/test-importer.js index 0324b61f..69ec06a4 100644 --- a/test/test-importer.js +++ b/test/test-importer.js @@ -68,7 +68,7 @@ module.exports = function (repo) { done() } }) - i.on('err', (err) => { + i.on('error', (err) => { expect(err).to.not.exist }) i.add({path: 'foo/bar/200Bytes.txt', stream: r}) @@ -152,7 +152,7 @@ module.exports = function (repo) { done() } }) - i.on('err', (err) => { + i.on('error', (err) => { expect(err).to.not.exist }) i.add({path: 'pim/200Bytes.txt', stream: r1}) @@ -193,7 +193,7 @@ module.exports = function (repo) { done() } }) - i.on('err', (err) => { + i.on('error', (err) => { expect(err).to.not.exist }) i.add({path: 'pam/pum/200Bytes.txt', stream: r1})