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

cat interface-core upgrades #316

Merged
merged 2 commits into from
Jun 7, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"form-data": "^1.0.0-rc3",
"gulp": "^3.9.1",
"idb-plus-blob-store": "^1.1.2",
"interface-ipfs-core": "^0.2.2",
"interface-ipfs-core": "^0.3.0",
"left-pad": "^1.1.0",
"lodash": "^4.11.2",
"mocha": "^2.5.1",
Expand All @@ -67,7 +67,7 @@
"glob": "^7.0.3",
"hapi": "^13.4.1",
"ipfs-bitswap": "^0.4.1",
"ipfs-api": "^5.0.1",
"ipfs-api": "^6.0.1",
"ipfs-block": "^0.3.0",
"ipfs-block-service": "^0.4.0",
"ipfs-merkle-dag": "^0.6.0",
Expand Down
6 changes: 2 additions & 4 deletions src/cli/commands/files/cat.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,11 @@ module.exports = Command.extend({
})
return
}
ipfs.files.cat(path, (err, res) => {
ipfs.files.cat(path, (err, file) => {
if (err) {
throw (err)
}
res.on('data', (data) => {
data.content.pipe(process.stdout)
})
file.pipe(process.stdout)
})
})
}
Expand Down
1 change: 1 addition & 0 deletions src/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,6 @@ function IPFS (repoInstance) {
this.object = object(this)
this.libp2p = libp2p(this)
this.files = files(this)
this.cat = files(this).cat // Alias for js-ipfs-api cat
this.bitswap = bitswap(this)
}
13 changes: 10 additions & 3 deletions src/core/ipfs/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,11 @@ module.exports = function files (self) {
i.end()
}),

cat: (hash, callback) => {
cat: promisify((hash, callback) => {
if (typeof hash === 'function') {
callback = hash
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does nothing

return callback('You must supply a multihash', null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An error should be a Error object

new Error('You must supply a multihash')

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, no need for null

}
self._dagS.get(hash, (err, fetchedNode) => {
if (err) {
return callback(err, null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for null

Expand All @@ -110,10 +114,13 @@ module.exports = function files (self) {
callback('This dag node is a directory', null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for null

} else {
const exportStream = Exporter(hash, self._dagS)
callback(null, exportStream)
exportStream.once('data', (object) => {
callback(null, object.content)
})
}
})
},
}),

get: (hash, callback) => {
var exportFile = Exporter(hash, self._dagS)
callback(null, exportFile)
Expand Down
2 changes: 1 addition & 1 deletion src/http-api/resources/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ exports.cat = {
}).code(500)
}
stream.on('data', (data) => {
return reply(data.content)
return reply(data)
})
})
}
Expand Down