Skip to content
This repository was archived by the owner on Aug 12, 2020. It is now read-only.

fix(importer): cleanup smaller issues #32

Merged
merged 2 commits into from
Apr 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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": [
Expand Down
13 changes: 8 additions & 5 deletions src/importer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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()
}

Expand All @@ -134,6 +136,7 @@ function Importer (dagService, options) {
return done(cb)
})
}))

function done (cb) {
counter--
cb()
Expand Down Expand Up @@ -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')
}
})

Expand Down
6 changes: 3 additions & 3 deletions test/test-importer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down Expand Up @@ -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})
Expand Down Expand Up @@ -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})
Expand Down