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

Commit 244611d

Browse files
fix some more tests
1 parent eb54fea commit 244611d

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

src/exporter/index.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
const traverse = require('pull-traverse')
44
const pull = require('pull-stream')
5+
<<<<<<< HEAD:src/exporter/index.js
56
const CID = require('cids')
7+
=======
8+
const isIPFS = require('is-ipfs')
9+
>>>>>>> fix some more tests:src/exporter.js
610

711
const util = require('./../util')
812
const switchType = util.switchType
@@ -12,12 +16,11 @@ const dirExporter = require('./dir')
1216
const fileExporter = require('./file')
1317

1418
module.exports = (hash, ipldResolver, options) => {
15-
try {
16-
hash = cleanMultihash(hash)
17-
} catch (err) {
18-
return pull.error(err)
19+
if (!isIPFS.multihash(hash)) {
20+
return pull.error(new Error('not valid multihash'))
1921
}
2022

23+
hash = cleanMultihash(hash)
2124
options = options || {}
2225

2326
function visitor (item) {

src/importer.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,14 @@ module.exports = (dagService, options) => {
2828
null,
2929
100,
3030
(err) => {
31-
if (err) return source.end(err)
31+
if (err) {
32+
return source.end(err)
33+
}
3234

33-
createAndStoreTree(files, dagService, source, () => {
35+
createAndStoreTree(files, dagService, source, (err) => {
36+
if (err) {
37+
return source.end(err)
38+
}
3439
source.end()
3540
})
3641
}

src/util.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
const UnixFS = require('ipfs-unixfs')
44
const pull = require('pull-stream')
55
const mh = require('multihashes')
6-
const isIPFS = require('is-ipfs')
76
const parallel = require('async/parallel')
87

98
exports.switchType = (node, dirHandler, fileHandler) => {
@@ -17,10 +16,6 @@ exports.switchType = (node, dirHandler, fileHandler) => {
1716
}
1817

1918
exports.cleanMultihash = (multihash) => {
20-
if (!isIPFS.multihash(multihash)) {
21-
throw new Error('not valid multihash')
22-
}
23-
2419
if (Buffer.isBuffer(multihash)) {
2520
return mh.toB58String(multihash)
2621
}

0 commit comments

Comments
 (0)