diff --git a/ipfsspec/async_ipfs.py b/ipfsspec/async_ipfs.py index 06d3c9e..6506883 100644 --- a/ipfsspec/async_ipfs.py +++ b/ipfsspec/async_ipfs.py @@ -66,7 +66,14 @@ async def ls(self, path, session): res = await self.api_get("ls", session, arg=path) self._raise_not_found_for_status(res, path) resdata = await res.json() - types = {1: "directory", 2: "file"} + types = { + 0: "raw", + 1: "directory", + 2: "file", + 3: "metadata", + 4: "symlink", + 5: "shard", + } return [{ "name": path + "/" + link["Name"], "CID": link["Hash"], diff --git a/ipfsspec/core.py b/ipfsspec/core.py index cdd881b..4a9a481 100644 --- a/ipfsspec/core.py +++ b/ipfsspec/core.py @@ -15,6 +15,14 @@ class IPFSGateway: + """ + Abstrats the IPFS gateway REST API. + + Documentation for the REST API can be found here: [Kubo_RPC_API]_. + + References: + .. [Kubo_RPC_API] http://docs.ipfs.tech.ipns.localhost:8080/reference/kubo/rpc/ + """ def __init__(self, url): self.url = url self.state = "unknown" @@ -166,7 +174,23 @@ def ls(self, path, detail=True, **kwargs): logger.debug("ls on %s", path) res = self._gw_apipost("ls", arg=path) links = res["Objects"][0]["Links"] - types = {1: "directory", 2: "file"} + + # Documentation for the type codes doesn't seem to have a great location. + # Currently 2023-10-17, the ls API docs specify the ls return + # structure, but not what the type integers mean: + # http://docs.ipfs.tech/reference/kubo/rpc/#api-v0-ls + # Some information about type codes can be found here: + # https://ipfs-search.readthedocs.io/en/latest/ipfs_datatypes.html + # https://github.com/ipfs/go-unixfs/blob/master/pb/unixfs.proto + + types = { + 0: "raw", + 1: "directory", + 2: "file", + 3: "metadata", + 4: "symlink", + 5: "shard", + } if detail: return [{"name": path + "/" + link["Name"], "size": link["Size"],