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

Commit

Permalink
feat: migrate core to use new async DAGNode interface
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddias committed Oct 29, 2016
1 parent 5dbb799 commit 254afdc
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 88 deletions.
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@
},
"homepage": "https://github.com/ipfs/js-ipfs#readme",
"devDependencies": {
"aegir": "^8.0.1",
"aegir": "^8.1.2",
"buffer-loader": "0.0.1",
"chai": "^3.5.0",
"execa": "^0.5.0",
"expose-loader": "^0.7.1",
"form-data": "^2.0.0",
"fs-pull-blob-store": "^0.4.1",
"gulp": "^3.9.1",
"interface-ipfs-core": "^0.15.0",
"interface-ipfs-core": "^0.16.6",
"left-pad": "^1.1.1",
"lodash": "^4.15.0",
"ncp": "^2.0.0",
Expand All @@ -70,14 +70,15 @@
"glob": "^7.0.6",
"hapi": "^15.0.3",
"idb-pull-blob-store": "^0.5.1",
"ipfs-api": "^9.0.0",
"ipfs-api": "^10.0.0",
"ipfs-bitswap": "^0.7.0",
"ipfs-block": "^0.4.0",
"ipfs-block-service": "^0.6.0",
"ipfs-multipart": "^0.1.0",
"ipfs-repo": "^0.10.0",
"ipfs-unixfs": "^0.1.4",
"ipfs-unixfs-engine": "^0.11.3",
"ipfs-unixfs-engine": "^0.12.0",
"ipld-resolver": "^0.1.1",
"isstream": "^0.1.2",
"joi": "^9.0.4",
"libp2p-ipfs": "^0.14.1",
Expand All @@ -97,7 +98,7 @@
"peer-id": "^0.7.0",
"peer-info": "^0.7.1",
"promisify-es6": "^1.0.1",
"pull-file": "^1.1ed.0",
"pull-file": "^1.0.0",
"pull-paramap": "^1.1.6",
"pull-pushable": "^2.0.1",
"pull-sort": "^1.0.0",
Expand Down
21 changes: 14 additions & 7 deletions src/core/components/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module.exports = function files (self) {

add: promisify((data, callback) => {
if (!callback || typeof callback !== 'function') {
callback = function noop () {}
callback = noop
}

pull(
Expand Down Expand Up @@ -97,17 +97,22 @@ module.exports = function files (self) {
}
}

function prepareFile (self, file, cb) {
function prepareFile (self, file, callback) {
const bs58mh = multihashes.toB58String(file.multihash)
self.object.get(file.multihash, (err, node) => {
if (err) {
return cb(err)
return callback(err)
}

cb(null, {
path: file.path || bs58mh,
hash: bs58mh,
size: node.size()
node.size((err, size) => {
if (err) {
return callback(err)
}
callback(null, {
path: file.path || bs58mh,
hash: bs58mh,
size: size
})
})
})
}
Expand Down Expand Up @@ -147,3 +152,5 @@ function normalizeContent (content) {
return data
})
}

function noop () {}
Loading

0 comments on commit 254afdc

Please sign in to comment.