-
Notifications
You must be signed in to change notification settings - Fork 299
fix: files ls inconsisntency #776
base: master
Are you sure you want to change the base?
Conversation
@@ -8,7 +8,7 @@ const transform = function (res, callback) { | |||
callback(null, entries.map((entry) => { | |||
return { | |||
name: entry.Name, | |||
type: entry.Type, | |||
type: (entry.Type === 0) ? 'file' : 'directory', |
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.
The unixfs type for file
is 2, and directory
is 1.
Sources:
[0] https://github.com/ipfs/js-ipfs-unixfs/blob/master/src/unixfs.proto.js#L6,L7
[1] https://github.com/ipfs/js-ipfs/blob/master/src/http/api/resources/files.js#L323,L332
Also per source [1], it appears that js-ipfs-unixfs-engine
uses dir
[2] instead of directory
. However, js-ipfs-unixfs
defines the string type as directory
[3].
[2] https://github.com/ipfs/js-ipfs-unixfs-engine/blob/master/src/exporter/dir-flat.js#L32
[3] https://github.com/ipfs/js-ipfs-unixfs/blob/master/src/index.js#L11
I'm unsure if this is going to cause a conflict immediately though, but it looks like js-ipfs-unixfs-engine
should be updated as well at some point.
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.
The unixfs type for file is 2, and directory is 1.
That's strange, because I'm getting 0s for files and 1s for directories... Hmmm, well, I'll take a look at this later then. 😄
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.
What are the numbers in go-ipfs?
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.
They are here: https://github.com/ipfs/go-ipfs/blob/v0.4.15/mfs/system.go#L39-L42 (I ran into this separately.) Talking with @whyrusleeping on IRC about it, because a) confusing and b) not well documented. I'd also expected them to match UnixFS.
@alanshaw what do you think about this? |
@alanshaw what's the state of this PR? The same for ipfs-inactive/interface-js-ipfs-core#282 |
@hacdias did you see the comments here ipfs-inactive/interface-js-ipfs-core#282 (comment) ? |
@alanshaw I believe I missed it!! Just read the comments. I'll work on those points. I'll close this PR as soon as I open a new one since this is a bit out of date. |
It is stated on interface-ipfs-core that
files.ls
type's must be strings (file
ordirectory
).Tests: ipfs-inactive/interface-js-ipfs-core#282