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

refactor: use unixfs exporter with CID instances #44

Merged
merged 2 commits into from
Mar 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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": "~0.36.0",
"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