ipld/unixfs: Dagreader ignores internal data node when links are present
Hello!
I'm currently studying a use case for go-ipfs in which a file node contains links to other versions of itself.
This all works well until the root file becomes small enough to fit inside the root's data node. Then, accessing the file through ipfs cat or the gateway skips the data node and goes on to read from the child nodes.
After investigating the bug, I found that it originated from go-unixfs, and especially the dagreader.
More precisely, https://github.com/ipfs/go-unixfs/blob/68c015a6f317ed5e21a4870f7c423a4b38b90a96/io/dagreader.go#L175-L179
I already have a fix for this if there is any interest, although it relies on the empirical assumption that we should stop descending through the DAG when we read a node that has named links (len(node.Links()[0].Name) != 0).
This would also close https://github.com/ipfs/go-ipfs/issues/7190 , which I opened a month ago.
This may be solved with the migration to a newer unixfs parser like https://github.com/ipfs/go-unixfsnode