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

Commit

Permalink
fix(importer): cleanup smaller issues
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed Apr 22, 2016
1 parent 6d843af commit eab17fe
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"ipfs-blocks": "^0.2.0",
"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

0 comments on commit eab17fe

Please sign in to comment.