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

Commit c4aab40

Browse files
committed
Merge remote-tracking branch 'remotes/origin/refactor/use-exporter-w-cid-instances' into add-http-dag-api
2 parents 38d9c3b + 2610979 commit c4aab40

File tree

6 files changed

+19
-12
lines changed

6 files changed

+19
-12
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,12 @@
108108
"ipfs-block-service": "~0.15.1",
109109
"ipfs-http-client": "^29.0.0",
110110
"ipfs-http-response": "~0.2.1",
111-
"ipfs-mfs": "~0.9.1",
111+
"ipfs-mfs": "github:ipfs/js-ipfs-mfs#refactor/use-exporter-w-cid-instances",
112112
"ipfs-multipart": "~0.1.0",
113113
"ipfs-repo": "~0.26.1",
114114
"ipfs-unixfs": "~0.1.16",
115-
"ipfs-unixfs-engine": "~0.35.3",
115+
"ipfs-unixfs-exporter": "~0.36.0",
116+
"ipfs-unixfs-importer": "~0.38.4",
116117
"ipld": "~0.21.1",
117118
"ipld-bitcoin": "~0.1.8",
118119
"ipld-dag-pb": "~0.15.0",

src/core/components/files-regular/add-pull-stream.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
const { importer } = require('ipfs-unixfs-engine')
3+
const importer = require('ipfs-unixfs-importer')
44
const pull = require('pull-stream')
55
const toPull = require('stream-to-pull-stream')
66
const waterfall = require('async/waterfall')

src/core/components/files-regular/cat-pull-stream.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
const { exporter } = require('ipfs-unixfs-engine')
3+
const exporter = require('ipfs-unixfs-exporter')
44
const pull = require('pull-stream')
55
const deferred = require('pull-defer')
66
const { normalizePath } = require('./utils')

src/core/components/files-regular/get-pull-stream.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
const { exporter } = require('ipfs-unixfs-engine')
3+
const exporter = require('ipfs-unixfs-exporter')
44
const pull = require('pull-stream')
55
const errCode = require('err-code')
66
const { normalizePath } = require('./utils')
@@ -21,6 +21,13 @@ module.exports = function (self) {
2121
self._preload(pathComponents[0])
2222
}
2323

24-
return exporter(ipfsPath, self._ipld, options)
24+
return pull(
25+
exporter(ipfsPath, self._ipld, options),
26+
pull.map(file => {
27+
file.hash = file.cid.toString()
28+
delete file.cid
29+
return file
30+
})
31+
)
2532
}
2633
}

src/core/components/files-regular/ls-pull-stream.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
'use strict'
22

3-
const { exporter } = require('ipfs-unixfs-engine')
3+
const exporter = require('ipfs-unixfs-exporter')
44
const pull = require('pull-stream')
5-
const CID = require('cids')
65
const { normalizePath } = require('./utils')
76

87
module.exports = function (self) {
@@ -26,7 +25,8 @@ module.exports = function (self) {
2625
recursive ? node.depth >= pathDepth : node.depth === pathDepth
2726
),
2827
pull.map(node => {
29-
node.hash = new CID(node.hash).toBaseEncodedString()
28+
node.hash = node.cid.toString()
29+
delete node.cid
3030
delete node.content
3131
return node
3232
})

src/http/api/resources/file.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
'use strict'
22

33
const isIpfs = require('is-ipfs')
4-
const unixfsEngine = require('ipfs-unixfs-engine')
5-
const exporter = unixfsEngine.exporter
4+
const exporter = require('ipfs-unixfs-exporter')
65
const pull = require('pull-stream')
76
const toB58String = require('multihashes').toB58String
87
const Boom = require('boom')
@@ -82,7 +81,7 @@ exports.ls = {
8281
const links = []
8382
files.forEach((file) => {
8483
if (file.depth === rootDepth) {
85-
const id = toB58String(file.hash)
84+
const id = file.cid.toString()
8685
res.Arguments[path] = id
8786
res.Objects[id] = toFileObject(file)
8887
res.Objects[id].Links = file.type === 'file' ? null : links

0 commit comments

Comments
 (0)