Skip to content

feat: handle UnixFS directory entries in ipfs-retriever #696

Description

@BravoNatalie

Description

Requesting a path that resolves to a UnixFS directory returns 404 Not Found from processIpfsResponse. The check entry.type !== 'file' && entry.type !== 'raw' hard-rejects directory entries with no explanation, making the error indistinguishable from a missing resource.

The blocks needed for listing are already present: the SP (Curio/frisbii) returns a path-scoped CAR with dag-scope=all, which includes the directory block and all immediate child link metadata. The 404 is a missing implementation, not an architectural constraint.

Proposed solution

In processIpfsResponse, detect entry.type === 'directory' and handle it separately instead of rejecting it. In
v13.7.3, use entry.content() (not entry.entries()) to iterate children. By default it fetches each child block and resolves a full entry with type, name, path, cid, and size, no extra SP requests are needed because frisbii's dag-scope=all already includes all child blocks in the CAR stream, and blockReadConcurrency: 1 ensures they're consumed in the same DFS order frisbii wrote them.

Done criteria

  • GET ipfsRootCid/ or ipfsRootCid/subdir/ where it resolves to a UnixFS directory returns an HTML or JSON listing of its children
  • Response includes correct Content-Type (text/html or application/json)
  • A file path that resolves to a file continues to stream raw bytes as before
  • Tests cover directory listing response and unchanged file streaming behaviour

Notes

Once you start consuming entry.content() to build the listing, the CAR stream advances past those child blocks. If you later try to serve one of those children's file bytes using the same blockstore, blocksReader.next() will return the wrong block.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    • Status
      No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions