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

Commit

Permalink
feat: Add offset/length arguments to files.cat
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed Apr 23, 2018
1 parent 7c5cea5 commit 33c973a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"ipfs-block": "~0.7.1",
"ipfs-unixfs": "~0.1.14",
"ipld-dag-cbor": "^0.12.0",
"ipld-dag-pb": "^0.14.2",
"ipld-dag-pb": "^0.14.3",
"is-ipfs": "^0.3.2",
"is-stream": "^1.1.0",
"libp2p-crypto": "^0.13.0",
Expand Down Expand Up @@ -77,9 +77,9 @@
"go-ipfs-dep": "^0.4.14",
"gulp": "^3.9.1",
"hapi": "^17.3.1",
"interface-ipfs-core": "~0.61.0",
"interface-ipfs-core": "^0.64.0",
"ipfs": "~0.28.2",
"ipfsd-ctl": "~0.32.0",
"ipfsd-ctl": "^0.32.1",
"pre-commit": "^1.2.2",
"pull-stream": "^3.6.7",
"socket.io": "^2.1.0",
Expand Down
7 changes: 6 additions & 1 deletion src/files/cat-pull-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ module.exports = (send) => {
}
}

send({ path: 'cat', args: hash, buffer: opts.buffer }, (err, stream) => {
const query = {
offset: opts.offset,
length: opts.length
}

send({ path: 'cat', args: hash, buffer: opts.buffer, qs: query }, (err, stream) => {
if (err) { return p.end(err) }

p.resolve(toPull(stream))
Expand Down
7 changes: 6 additions & 1 deletion src/files/cat-readable-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ module.exports = (send) => {
}
}

send({ path: 'cat', args: hash, buffer: opts.buffer }, (err, stream) => {
const query = {
offset: opts.offset,
length: opts.length
}

send({ path: 'cat', args: hash, buffer: opts.buffer, qs: query }, (err, stream) => {
if (err) { return pt.destroy(err) }

pump(stream, pt)
Expand Down
7 changes: 6 additions & 1 deletion src/files/cat.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ module.exports = (send) => {
}
}

send({ path: 'cat', args: hash, buffer: opts.buffer }, (err, stream) => {
const query = {
offset: opts.offset,
length: opts.length
}

send({ path: 'cat', args: hash, buffer: opts.buffer, qs: query }, (err, stream) => {
if (err) { return callback(err) }

stream.pipe(bl((err, data) => {
Expand Down

0 comments on commit 33c973a

Please sign in to comment.