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

Commit ec6bd39

Browse files
committed
Merge pull request #32 from ipfs/fix/race
fix(importer): cleanup smaller issues
2 parents 6d843af + a9b20a2 commit ec6bd39

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
"buffer-loader": "0.0.1",
4141
"chai": "^3.5.0",
4242
"fs-blob-store": "^5.2.1",
43-
"idb-plus-blob-store": "^1.0.0",
44-
"ipfs-repo": "^0.6.1",
43+
"idb-plus-blob-store": "^1.1.1",
44+
"ipfs-repo": "^0.6.6",
4545
"ncp": "^2.0.0",
4646
"pre-commit": "^1.1.2",
4747
"raw-loader": "^0.5.1",
@@ -54,10 +54,10 @@
5454
"block-stream2": "^1.1.0",
5555
"debug": "^2.2.0",
5656
"eventemitter2": "^1.0.0",
57-
"ipfs-blocks": "^0.2.0",
57+
"ipfs-blocks": "^0.2.1",
5858
"ipfs-merkle-dag": "^0.4.0",
5959
"ipfs-unixfs": "^0.1.0",
60-
"readable-stream": "2.0.6",
60+
"readable-stream": "^1.1.13",
6161
"through2": "^2.0.0"
6262
},
6363
"contributors": [

src/importer.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ function Importer (dagService, options) {
4141
n.data = d.marshal()
4242
dagService.add(n, (err) => {
4343
if (err) {
44-
return this.emit('err', 'Failed to store' + fl.path)
44+
this.emit('error', `Failed to store: ${fl.path}`)
45+
return
4546
}
4647
const el = {
4748
path: fl.path,
@@ -72,9 +73,10 @@ function Importer (dagService, options) {
7273
const l = new UnixFS('file', chunk)
7374
const n = new merkleDAG.DAGNode(l.marshal())
7475

75-
dagService.add(n, function (err) {
76+
dagService.add(n, (err) => {
7677
if (err) {
77-
return this.emit('err', 'Failed to store chunk of' + fl.path)
78+
this.emit('error', `Failed to store chunk of: ${fl.path}`)
79+
return cb(err)
7880
}
7981

8082
leaves.push({
@@ -118,7 +120,7 @@ function Importer (dagService, options) {
118120
n.data = f.marshal()
119121
dagService.add(n, (err) => {
120122
if (err) {
121-
this.emit('err', 'Failed to store' + fl.path)
123+
this.emit('error', `Failed to store: ${fl.path}`)
122124
return cb()
123125
}
124126

@@ -134,6 +136,7 @@ function Importer (dagService, options) {
134136
return done(cb)
135137
})
136138
}))
139+
137140
function done (cb) {
138141
counter--
139142
cb()
@@ -242,7 +245,7 @@ function Importer (dagService, options) {
242245
n.data = d.marshal()
243246
dagService.add(n, (err) => {
244247
if (err) {
245-
this.emit('err', 'failed to store dirNode')
248+
this.emit('error', 'failed to store dirNode')
246249
}
247250
})
248251

test/test-importer.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ module.exports = function (repo) {
6868
done()
6969
}
7070
})
71-
i.on('err', (err) => {
71+
i.on('error', (err) => {
7272
expect(err).to.not.exist
7373
})
7474
i.add({path: 'foo/bar/200Bytes.txt', stream: r})
@@ -152,7 +152,7 @@ module.exports = function (repo) {
152152
done()
153153
}
154154
})
155-
i.on('err', (err) => {
155+
i.on('error', (err) => {
156156
expect(err).to.not.exist
157157
})
158158
i.add({path: 'pim/200Bytes.txt', stream: r1})
@@ -193,7 +193,7 @@ module.exports = function (repo) {
193193
done()
194194
}
195195
})
196-
i.on('err', (err) => {
196+
i.on('error', (err) => {
197197
expect(err).to.not.exist
198198
})
199199
i.add({path: 'pam/pum/200Bytes.txt', stream: r1})

0 commit comments

Comments
 (0)