This repository was archived by the owner on Feb 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: jsipfs ls -r (Recursive list directory) #1222
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
6c0d8a0
Initial work on js-ipfs ls -r. Realized that I prefer adding an optio…
JonKrone e0ff5ba
checkpoint commit. barebones impl passing args through ipfs.ls
JonKrone cb27a71
clean up impl of 'ipfs ls -r'. Lots of failing tests, unsure if they'…
JonKrone a8a4b84
consider 'ipfs ls' as an alias to 'ipfs files ls'
JonKrone 6ef9d90
deprecate 'ipfs file ls'
JonKrone 9957557
trace failure of js-ipfs ls 'public ipfs path' to print. Checkpoint w…
JonKrone acf38e5
line ending conversion seemed to break tests. reverting and reseting …
JonKrone fb18080
adjust padding to account for subdirs, add ls -r test for same.
JonKrone 74ba38a
don't overwrite error response
JonKrone 50ac0dc
copy ls test to test/cli/ls, might remove or dedupe files ls tests.
JonKrone 0c818b7
clean tests. Gotta take another look at files ls vs ls
JonKrone b3d254c
remove files ls
JonKrone 68d1724
convert files parseArgs to use CIDs,
JonKrone e695b2d
clean tests, migrate mh to CID, takeover an error http response.
JonKrone f12b416
clean
JonKrone dd202fc
lint fixes
JonKrone e20c9de
alias 'ipfs files ls' to 'ipfs ls'
JonKrone 7da6126
update ipfs-api dep
JonKrone 303e480
update ls test for non-existant files. Had an unhandled rejection war…
JonKrone 5fa1c3d
gah! mocha uses the arity of the test function to determine whether t…
JonKrone File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* eslint-env mocha */ | ||
'use strict' | ||
|
||
const expect = require('chai').expect | ||
const runOnAndOff = require('../utils/on-and-off') | ||
|
||
describe('ls', () => runOnAndOff((thing) => { | ||
let ipfs | ||
|
||
before(() => { | ||
ipfs = thing.ipfs | ||
return ipfs('files add -r test/fixtures/test-data/recursive-get-dir') | ||
}) | ||
|
||
it('prints added files', function () { | ||
this.timeout(20 * 1000) | ||
return ipfs('ls QmYmW4HiZhotsoSqnv2o1oUusvkRM8b9RweBoH7ao5nki2') | ||
.then((out) => { | ||
expect(out).to.eql( | ||
'QmQQHYDwAQms78fPcvx1uFFsfho23YJNoewfLbi9AtdyJ9 123530 blocks/\n' + | ||
'QmPkWYfSLCEBLZu7BZt4kigGDMe3cpogMbeVf97gN2xJDN 3939 config\n' + | ||
'Qma13ZrhKG52MWnwtZ6fMD8jGj8d4Q9sJgn5xtKgeZw5uz 5503 datastore/\n' + | ||
'QmUhUuiTKkkK8J6JZ9zmj8iNHPuNfGYcszgRumzhHBxEEU 7397 init-docs/\n' + | ||
'QmR56UJmAaZLXLdTT1ALrE9vVqV8soUEekm9BMd4FnuYqV 10 version\n' | ||
) | ||
}) | ||
}) | ||
|
||
it('prints nothing for non-existant hashes', function () { | ||
// If the daemon is off, ls should fail | ||
// If the daemon is on, ls should search until it hits a timeout | ||
return Promise.race([ | ||
ipfs.fail('ls QmYmW4HiZhotsoSqnv2o1oSssvkRM8b9RweBoH7ao5nki2'), | ||
new Promise((res, rej) => setTimeout(res, 4000)) | ||
]) | ||
.catch(() => expect.fail(0, 1, 'Should have thrown or timedout')) | ||
}) | ||
|
||
it('adds a header, -v', function () { | ||
this.timeout(20 * 1000) | ||
return ipfs('ls /ipfs/QmYmW4HiZhotsoSqnv2o1oUusvkRM8b9RweBoH7ao5nki2 -v') | ||
.then((out) => { | ||
expect(out).to.eql( | ||
'Hash Size Name\n' + | ||
'QmQQHYDwAQms78fPcvx1uFFsfho23YJNoewfLbi9AtdyJ9 123530 blocks/\n' + | ||
'QmPkWYfSLCEBLZu7BZt4kigGDMe3cpogMbeVf97gN2xJDN 3939 config\n' + | ||
'Qma13ZrhKG52MWnwtZ6fMD8jGj8d4Q9sJgn5xtKgeZw5uz 5503 datastore/\n' + | ||
'QmUhUuiTKkkK8J6JZ9zmj8iNHPuNfGYcszgRumzhHBxEEU 7397 init-docs/\n' + | ||
'QmR56UJmAaZLXLdTT1ALrE9vVqV8soUEekm9BMd4FnuYqV 10 version\n' | ||
) | ||
}) | ||
}) | ||
|
||
it('follows a path, <hash>/<subdir>', function () { | ||
this.timeout(20 * 1000) | ||
|
||
return ipfs('ls /ipfs/QmYmW4HiZhotsoSqnv2o1oUusvkRM8b9RweBoH7ao5nki2/init-docs') | ||
.then((out) => { | ||
expect(out).to.eql( | ||
'QmZTR5bcpQD7cFgTorqxZDYaew1Wqgfbd2ud9QqGPAkK2V 1688 about\n' + | ||
'QmYCvbfNbCwFR45HiNP45rwJgvatpiW38D961L5qAhUM5Y 200 contact\n' + | ||
'QmegvLXxpVKiZ4b57Xs1syfBVRd8CbucVHAp7KpLQdGieC 65 docs/\n' + | ||
'QmY5heUM5qgRubMDD1og9fhCPA6QdkMp3QCwd4s7gJsyE7 322 help\n' + | ||
'QmdncfsVm2h5Kqq9hPmU7oAVX2zTSVP3L869tgTbPYnsha 1728 quick-start\n' + | ||
'QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB 1102 readme\n' + | ||
'QmTumTjvcYCAvRRwQ8sDRxh8ezmrcr88YFU7iYNroGGTBZ 1027 security-notes\n' + | ||
'QmciSU8hfpAXKjvK5YLUSwApomGSWN5gFbP4EpDAEzu2Te 863 tour/\n' | ||
) | ||
}) | ||
}) | ||
|
||
it('recursively follows folders, -r', function () { | ||
this.slow(2000) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @JonKrone what does this call do? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. got it, it tells mocha to inform us that it is slow after 2000ms. |
||
this.timeout(20 * 1000) | ||
|
||
return ipfs('ls -r /ipfs/QmYmW4HiZhotsoSqnv2o1oUusvkRM8b9RweBoH7ao5nki2/init-docs') | ||
.then(out => { | ||
expect(out).to.eql( | ||
'QmZTR5bcpQD7cFgTorqxZDYaew1Wqgfbd2ud9QqGPAkK2V 1688 about\n' + | ||
'QmYCvbfNbCwFR45HiNP45rwJgvatpiW38D961L5qAhUM5Y 200 contact\n' + | ||
'QmegvLXxpVKiZ4b57Xs1syfBVRd8CbucVHAp7KpLQdGieC 65 docs/\n' + | ||
'QmQN88TEidd3RY2u3dpib49fERTDfKtDpvxnvczATNsfKT 14 index\n' + | ||
'QmY5heUM5qgRubMDD1og9fhCPA6QdkMp3QCwd4s7gJsyE7 322 help\n' + | ||
'QmdncfsVm2h5Kqq9hPmU7oAVX2zTSVP3L869tgTbPYnsha 1728 quick-start\n' + | ||
'QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB 1102 readme\n' + | ||
'QmTumTjvcYCAvRRwQ8sDRxh8ezmrcr88YFU7iYNroGGTBZ 1027 security-notes\n' + | ||
'QmciSU8hfpAXKjvK5YLUSwApomGSWN5gFbP4EpDAEzu2Te 863 tour/\n' + | ||
'QmYE7xo6NxbHEVEHej1yzxijYaNY51BaeKxjXxn6Ssa6Bs 807 0.0-intro\n' | ||
) | ||
}) | ||
}) | ||
})) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be suggesting
files ls
, right? per ipfs/specs#98 (comment)copied this from ipfs.io, will change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still just
ipfs ls
for now until both APIs are united. Currently,ipfs ls !== ipfs files ls
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I thought so but was a bit confused here. Tracing code, I found that
ipfs ls
is an alias ofipfs files ls
in js-ipfs/core -js-ipfs/src/core/index.js
Line 118 in 905bdc0
There is also no
/files/ls
route handler in js-ipfs and ajsipfs files ls
command with a daemon running triggers a js-ipfs-api/ls
, not/files/ls
, request. So there are a couple places where it seemsipfs ls == ipfs files ls
. I'm sure there's something that I'm missing, let's go over it Wednesday.