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

fix: files.cat: detect and handle errors when unknown path and cat dir #1143

Merged
merged 1 commit into from
Dec 12, 2017

Conversation

pgte
Copy link
Contributor

@pgte pgte commented Dec 12, 2017

Should fix #1142

@ghost ghost assigned pgte Dec 12, 2017
@ghost ghost added the status/in-progress In progress label Dec 12, 2017
@pgte
Copy link
Contributor Author

pgte commented Dec 12, 2017

Tests here: ipfs-inactive/interface-js-ipfs-core#182

@daviddias daviddias merged commit 120d291 into master Dec 12, 2017
@ghost ghost removed the status/in-progress In progress label Dec 12, 2017
@daviddias daviddias deleted the fix/cat-errors branch December 12, 2017 14:31
@daviddias
Copy link
Member

Will wait on ipfs-inactive/interface-js-ipfs-core#183 (review) to release this fix.

@@ -137,10 +137,19 @@ module.exports = function files (self) {
pull.collect((err, files) => {
if (err) { d.end(err) }
Copy link
Member

Choose a reason for hiding this comment

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

Is this missing a return?

}

const content = files[files.length - 1].content
if (files.length > 1) {
files = files.filter((file) => file.path === ipfsPath)
Copy link
Member

Choose a reason for hiding this comment

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

Here file.path is the path from the root e.g. tour and tour/0.0-intro, and ipfsPath is the full path e.g. /ipfs/QmfGBRT6BbWJd7yUc2uYdaUZJBbnEFvTqehPFoSMQ6wgdr/tour.

This filter is removing all the files from the array and so files[0] below is undefined

screen shot 2017-12-14 at 12 13 48

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @alanshaw !
#1148 should fix this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Theres's still an issue here, where "tour" dir is being filtered out prematurely because the output path doesn't match the input. Digging in...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

... which should be fixed f6c15c6

MicrowaveDev pushed a commit to galtproject/js-ipfs that referenced this pull request May 22, 2020
This reverts commit 9b1589c.

License: MIT
Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
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.

jsipfs cat on a directory not working correctly
3 participants