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

hash field missing in files but present for directories #189

Closed
arminvoid opened this issue Oct 7, 2017 · 3 comments
Closed

hash field missing in files but present for directories #189

arminvoid opened this issue Oct 7, 2017 · 3 comments
Labels
kind/question A question or request for support

Comments

@arminvoid
Copy link

Question
Sample code - https://github.com/ipfs/js-ipfs/blob/master/src/core/components/files.js#L87

const exporter = unixfsEngine.exporter
exporter(ipfsPath, self._ipldResolver)

Following list of objects is returned.

[ { path: 'QmTyckmyosocyFaeyL8fJWQLLndx845Lx5GG3MctWfLx45',
    hash: <Buffer 12 20 53 c2 b7 17 b5 86 90 a9 76 bc 7c ef a5 cd 90 4e 05 a9 ba 0d 50 35 8c 64 20 e2 db 85 2d bd f2 26> },
  { content: [Function],
    path: 'QmTyckmyosocyFaeyL8fJWQLLndx845Lx5GG3MctWfLx45/Video.mp4',
    size: 1114073 },
  { content: [Function],
    path: 'QmTyckmyosocyFaeyL8fJWQLLndx845Lx5GG3MctWfLx45/WRAPPER_UNSUPERVISED_DIFFBOT-queries',
    size: 2522 },
  { content: [Function],
    path: 'QmTyckmyosocyFaeyL8fJWQLLndx845Lx5GG3MctWfLx45/cobain.png',
    size: 181581 },
  { content: [Function],
    path: 'QmTyckmyosocyFaeyL8fJWQLLndx845Lx5GG3MctWfLx45/cobain2.png',
    size: 181581 } ]

The hash field is present only for directories (https://github.com/ipfs/js-ipfs-unixfs-engine/blob/master/src/exporter/dir-flat.js#L17) but not for files. Is this intended behaviour?

Happened to look in this code while trying to understand how js-ipfs files cat works as part of investigation to implement js-ipfs files ls command (ipfs/js-ipfs#927).

Adding a hash: node.multihash here https://github.com/ipfs/js-ipfs-unixfs-engine/blob/master/src/exporter/file.js#L43 would do the trick.

@daviddias daviddias added status/ready Ready to be worked kind/question A question or request for support labels Oct 13, 2017
@daviddias
Copy link
Contributor

@pgte mind providing context here?

@pgte
Copy link
Contributor

pgte commented Oct 20, 2017

Makes sense and checks out. I'm ok with this.

@daviddias
Copy link
Contributor

Merging. Thank you @atvanguard :)

@ghost ghost removed the status/ready Ready to be worked label Nov 7, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/question A question or request for support
Projects
None yet
Development

No branches or pull requests

3 participants