Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Difference of paths between recursive and normal calls #43

Open
AuHau opened this issue Oct 17, 2019 · 2 comments · May be fixed by dyna-dot/orbit-web#1
Open

Difference of paths between recursive and normal calls #43

AuHau opened this issue Oct 17, 2019 · 2 comments · May be fixed by dyna-dot/orbit-web#1
Labels
status/ready Ready to be worked

Comments

@AuHau
Copy link
Member

AuHau commented Oct 17, 2019

As part of ipfs/js-ipfs#2540 I was digging why there are different link.depth when ipfs ls is called recursively and non-recursively. I have tracked the inconsistency to how this exporter returns paths when called recursively and non-recursively.

When called using /ipfs/Qmaj2NmcyAXT8dFmZRRytE12wpcaHADzbChKToMEjBsj5Z/init-docs recursivelly, the result paths are:

  • QmUhUuiTKkkK8J6JZ9zmj8iNHPuNfGYcszgRumzhHBxEEU/contact
  • QmUhUuiTKkkK8J6JZ9zmj8iNHPuNfGYcszgRumzhHBxEEU/about
  • etc.

When called using /ipfs/Qmaj2NmcyAXT8dFmZRRytE12wpcaHADzbChKToMEjBsj5Z/init-docs non-recursivelly, the result paths are:

  • Qmaj2NmcyAXT8dFmZRRytE12wpcaHADzbChKToMEjBsj5Z/init-docs/contact
  • Qmaj2NmcyAXT8dFmZRRytE12wpcaHADzbChKToMEjBsj5Z/init-docs/about
  • etc.

Eq. the original /init-docs is suddenly part of the returned paths.

I believe there should be one way for both ways. What should be the right one?

@achingbrain
Copy link
Member

I think this is meant to be a reflection of what happens in bash, etc.

Given:

foo
├── bar.txt
└── baz/
    └── qux.txt
$ ls -l foo
total 3
-rw-r--r--   8 alex  staff  256  4 Oct 16:22 bar.txt
drwxr-xr-x  12 alex  staff  384  8 Oct 11:52 baz
$ ls -lR foo
total 3
-rw-r--r--   8 alex  staff  256  4 Oct 16:22 bar.txt
drwxr-xr-x  12 alex  staff  384  8 Oct 11:52 baz

foo/baz:
total 2
-rw-r--r--   1 alex  staff   838 20 May 15:44 qux.txt

In the second example the containing folder becomes part of the path - it prints foo/baz: instead of baz:.

That said, it'd certainly be simpler if it only worked one way, probably the second where the paths contain the CID the user has specified.

achingbrain referenced this issue in ipfs/js-ipfs Oct 17, 2019
* sanitises input to replace multiple slashes with single slashes
* removes trailing slashes
* uses `0` for padding when `link.depth` results in negative padding

N.b will be resolved in a better way by ipfs/js-ipfs-unixfs-exporter#24
@AuHau
Copy link
Member Author

AuHau commented Oct 17, 2019

For info: We agreed that the depth will be calculated as using full path. Hence
when

/ipfs/Qmaj2NmcyAXT8dFmZRRytE12wpcaHADzbChKToMEjBsj5Z/init-docs

returns

Qmaj2NmcyAXT8dFmZRRytE12wpcaHADzbChKToMEjBsj5Z/init-docs/contact

it will have depth 2.

achingbrain referenced this issue in ipfs/js-ipfs Oct 17, 2019
* sanitises input to replace multiple slashes with single slashes
* removes trailing slashes
* uses `0` for padding when `link.depth` results in negative padding

N.b will be resolved in a better way by ipfs/js-ipfs-unixfs-exporter#24
achingbrain referenced this issue in ipfs/js-ipfs Oct 17, 2019
* sanitises input to replace multiple slashes with single slashes
* removes trailing slashes
* uses `0` for padding when `link.depth` results in negative padding

N.b will be resolved in a better way by ipfs/js-ipfs-unixfs-exporter#24
achingbrain referenced this issue in ipfs/js-ipfs Oct 17, 2019
* sanitises input to replace multiple slashes with single slashes
* removes trailing slashes
* uses `0` for padding when `link.depth` results in negative padding

N.b will be resolved in a better way by ipfs/js-ipfs-unixfs-exporter#24
@achingbrain achingbrain transferred this issue from ipfs-inactive/js-ipfs-unixfs-exporter Feb 21, 2020
@jacobheun jacobheun added the status/ready Ready to be worked label Jun 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/ready Ready to be worked
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants