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

Adds API for ipfs.files.get. #28

Closed
wants to merge 2 commits into from

Conversation

hackergrrl
Copy link
Contributor

@hackergrrl hackergrrl commented Jun 7, 2016

@@ -278,8 +275,7 @@ module.exports = (common) => {
const hash = new Buffer(bs58.decode('QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB'))
ipfs.cat(hash)
.then((stream) => {
stream.pipe(bl((err, bldata) => {
expect(err).to.not.exist
stream.pipe(concat((bldata) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

bl was nice cause it also catched any error

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The stream will still throw, which isn't as nice as the explicit handling.

@hackergrrl
Copy link
Contributor Author

Let me know if LGTM and I'll squash for ya! @diasdavid

@daviddias
Copy link
Contributor

daviddias commented Jun 28, 2016

Merged the js-ipfs-unixfs-engine PR.

Are these the ones missing on js-ipfs-api and js-ipfs to get the tests from files.get working there?

Let's squash these, get js-ipfs ready, both passing the tests and put a ✔️ on this :)

@daviddias
Copy link
Contributor

@noffle I believe I unlocked you by merging and releasing the unixfs-engine PR. Let me know if you need anything else from me :)

@daviddias
Copy link
Contributor

@noffle this is looking good. Could you squash the commits for the merge and also, follow ipfs-inactive/js-ipfs-unixfs-engine#52 (comment) so that PR gets merged too.

Excited to have the get command finally in too :)

stream.pipe(concat((files) => {
expect(err).to.not.exist
expect(files).to.be.length(1)
expect(files[0].path).to.equal(hash)
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems that here you expect that the path is a string b58 encoded multihash, while... ->

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The correct thing to do is to check for the bs58-encoded value. If you're seeing anything else it's definitely an error to accommodate pre-this-PR. Thanks for noticing.

@daviddias
Copy link
Contributor

There are some lint errors, but I guess that is our bad for not having added CLI just to test that.

/Users/david/code/interface-ipfs-core/src/files.js
    9:7    error  'isNode' is defined but never used  no-unused-vars
   29:101  error  Unexpected trailing comma           comma-dangle
  367:70   error  Unexpected trailing comma           comma-dangle
  384:41   error  Unexpected trailing comma           comma-dangle

Adding CI now

@daviddias
Copy link
Contributor

@noffle got ipfs-inactive/js-ipfs-http-client#296 (comment), which makes me think something is weird with js-ipfs since it doesn't error.

@hackergrrl hackergrrl force-pushed the ipfs-get branch 2 times, most recently from 6ae5088 to e656e7c Compare August 5, 2016 23:44
@hackergrrl
Copy link
Contributor Author

The multihash buffer vs bs58-encoded string is an old breakage; forgot to push the fix. This was what I addressed in js-ipfs-unixfs-engine a while back.

Update: worse! Somehow my commits got merged twice on this branch -- what a mess. I went back and re-rebased my way to a much cleaner state. Tests pass now for me, commits are squashed, linting is done! 👌


module.exports = (common) => {
describe('.files', () => {
describe.only('.files', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Will need to change this. But I can also do it on merge :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agh, I'm guilty of continually doing this. Will correct. :)

@daviddias
Copy link
Contributor

Thank you! I got an error in js-ipfs-api browser tests though, see: https://github.com/ipfs/js-ipfs-api/pull/296/files#r73787506

Also, in js-ipfs, I'm now getting:

  1) core --both .files .get with a multihash:
     Uncaught AssertionError: expected <Buffer 12 20 12 0f 6a f6 01 d4 6e 10 b2 d2 e1 1e d7 1c 55 d2 5f 30 42 c2 25 01 e4 1d 12 46 e7 a1 e9 d3 d8 ec> to deeply equal 'QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB'

@@ -20,6 +20,7 @@
- [Files](/API/files)
- [`add`](/API/files#add)
- [`createAddStream`](/files#createaddstream)
- [`get`](/API/files#get)
Copy link
Contributor

Choose a reason for hiding this comment

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

@noffle seems that this was never added to the files.md. Maybe a missing commit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure where it got dropped. Thanks for noticing! I'll re-add.

@hackergrrl
Copy link
Contributor Author

Closing this in favour of #54.

@hackergrrl hackergrrl closed this Aug 9, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants