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

Commit

Permalink
refactor: use unixfs exporter with CID instances
Browse files Browse the repository at this point in the history
Allows MFS to use the unixfs exporter that exports CIDs without API changes.

refs ipfs-inactive/interface-js-ipfs-core#394

Depends on:

* [ ] ipfs-inactive/js-ipfs-unixfs-exporter#19

License: MIT
Signed-off-by: Alan Shaw <alan@tableflip.io>
  • Loading branch information
alanshaw committed Feb 27, 2019
1 parent b47c0b0 commit e6fa97a
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"interface-datastore": "~0.6.0",
"ipfs-multipart": "~0.1.0",
"ipfs-unixfs": "~0.1.16",
"ipfs-unixfs-exporter": "~0.35.5",
"ipfs-unixfs-exporter": "github:ipfs/js-ipfs-unixfs-exporter#refactor/export-cid-instances",
"ipfs-unixfs-importer": "~0.38.0",
"ipld-dag-pb": "~0.15.2",
"is-pull-stream": "~0.0.0",
Expand Down
4 changes: 2 additions & 2 deletions src/core/ls-pull-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ module.exports = (context) => {
}

loadNode(context, {
cid: file.hash
cid: file.cid
}, (err, result) => {
if (err) {
return cb(err)
Expand All @@ -114,7 +114,7 @@ module.exports = (context) => {
cb(null, {
name: file.name,
type: FILE_TYPES[meta.type],
hash: formatCid(file.hash, options.cidBase),
hash: formatCid(file.cid, options.cidBase),
size: meta.fileSize() || 0
})
})
Expand Down
3 changes: 1 addition & 2 deletions src/core/mkdir.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const pull = require('pull-stream/pull')
const filter = require('pull-stream/throughs/filter')
const map = require('pull-stream/throughs/map')
const collect = require('pull-stream/sinks/collect')
const CID = require('cids')
const {
createNode,
toMfsPath,
Expand Down Expand Up @@ -88,7 +87,7 @@ module.exports = (context) => {
exported = currentPath

return {
cid: new CID(node.hash),
cid: node.cid,
name: node.name
}
}),
Expand Down
5 changes: 2 additions & 3 deletions src/core/stat.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const pull = require('pull-stream/pull')
const collect = require('pull-stream/sinks/collect')
const asyncMap = require('pull-stream/throughs/async-map')
const exporter = require('ipfs-unixfs-exporter')
const CID = require('cids')
const log = require('debug')('ipfs:mfs:stat')

const defaultOptions = {
Expand Down Expand Up @@ -43,7 +42,7 @@ module.exports = (context) => {
asyncMap((file, cb) => {
if (options.hash) {
return cb(null, {
hash: formatCid(new CID(file.hash), options.cidBase)
hash: formatCid(file.cid, options.cidBase)
})
}

Expand All @@ -54,7 +53,7 @@ module.exports = (context) => {
}

loadNode(context, {
cid: file.hash
cid: file.cid
}, (err, result) => {
if (err) {
return cb(err)
Expand Down
3 changes: 1 addition & 2 deletions src/core/utils/to-trail.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const filter = require('pull-stream/throughs/filter')
const map = require('pull-stream/throughs/map')
const collect = require('pull-stream/sinks/collect')
const log = require('debug')('ipfs:mfs:utils:to-trail')
const CID = require('cids')

const toTrail = (context, path, options, callback) => {
const toExport = toPathComponents(path)
Expand Down Expand Up @@ -57,7 +56,7 @@ const toTrail = (context, path, options, callback) => {

return {
name,
cid: new CID(node.hash),
cid: node.cid,
size: node.size,
type: node.type
}
Expand Down

0 comments on commit e6fa97a

Please sign in to comment.