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

IPFS.files.ls returns integer not 'directory'/'file' in type attribute #3330

Closed
gcohler opened this issue Oct 16, 2020 · 4 comments · Fixed by #3352
Closed

IPFS.files.ls returns integer not 'directory'/'file' in type attribute #3330

gcohler opened this issue Oct 16, 2020 · 4 comments · Fixed by #3352
Labels
status/ready Ready to be worked

Comments

@gcohler
Copy link
Contributor

gcohler commented Oct 16, 2020

From what I can tell, the documentation and the implementation differ.

Documentation here: https://github.com/ipfs/js-ipfs/blob/master/docs/core-api/FILES.md#ipfsfileslspath-options.

What I received was a 1 for directory.

@gcohler gcohler added the need/triage Needs initial labeling and prioritization label Oct 16, 2020
@welcome
Copy link

welcome bot commented Oct 16, 2020

Thank you for submitting your first issue to this repository! A maintainer will be here shortly to triage and review.
In the meantime, please double-check that you have provided all the necessary information to make this process easy! Any information that can help save additional round trips is useful! We currently aim to give initial feedback within two business days. If this does not happen, feel free to leave a comment.
Please keep an eye on how this issue will be labeled, as labels give an overview of priorities, assignments and additional actions requested by the maintainers:

  • "Priority" labels will show how urgent this is for the team.
  • "Status" labels will show if this is ready to be worked on, blocked, or in progress.
  • "Need" labels will indicate if additional input or analysis is required.

Finally, remember to use https://discuss.ipfs.io if you just need general support.

@achingbrain
Copy link
Member

This should return a string in line with the docs - would you like to open a PR that fixes it?

@achingbrain achingbrain added status/ready Ready to be worked and removed need/triage Needs initial labeling and prioritization labels Oct 19, 2020
@gcohler
Copy link
Contributor Author

gcohler commented Oct 19, 2020

I don't know the code-base well enough. But I would suggest the following two changes (from my investigation).

  1. In the MFS_FILE_TYPES definition, there are two entries with the same number assigned. That appears to be a problem.

My proposal: In https://github.com/ipfs/js-ipfs/blob/master/packages/ipfs-core/src/utils.js. Change line 21 to:

  'hamt-sharded-directory': 2
  1. In the toOutput function it doesn't translate into a string.

My proposal: In https://github.com/ipfs/js-ipfs/blob/master/packages/ipfs-core/src/components/files/ls.js: Change line 18 to:

type = Object.entries(MFS_FILE_TYPES).find(x => x[1] == fsEntry.unixfs.type)[0];

@gcohler
Copy link
Contributor Author

gcohler commented Oct 24, 2020

@achingbrain I submitted a PR.

achingbrain added a commit that referenced this issue Oct 27, 2020
Supersedes #3345 #2939
Fixes #3330 #2948

BREAKING CHANGE: types returned by `ipfs.files.ls` are now strings, in line with the docs but different to previous behaviour

Co-authored-by: Geoffrey Cohler <g.cohler@computer.org>
SgtPooki referenced this issue in ipfs/js-kubo-rpc-client Aug 18, 2022
Supersedes #3345 #2939
Fixes #3330 #2948

BREAKING CHANGE: types returned by `ipfs.files.ls` are now strings, in line with the docs but different to previous behaviour

Co-authored-by: Geoffrey Cohler <g.cohler@computer.org>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status/ready Ready to be worked
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants