fsspec / ipfsspec

readonly python fsspec implementation for IPFS
MIT License
21 stars 10 forks source link

Ls fails when a directory contains symlinks (or anything that is not a file or directory). #26

Open Erotemic opened 1 year ago

Erotemic commented 1 year ago

I ran into an issue where running ls broke because "Type 4" was not recognized.

Unfortunately the ls rest docs are not helpful here:

http://docs.ipfs.tech.ipns.localhost:8080/reference/kubo/rpc/#api-v0-ls

But I was able to find this indicating what the different type codes meant:

https://ipfs-search.readthedocs.io/en/latest/ipfs_datatypes.html https://github.com/ipfs/go-unixfs/blob/master/pb/unixfs.proto

MWE:

import fsspec

import logging
import sys

logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)

import ipfsspec
fs = fsspec.get_filesystem_class('ipfs')

fs = ipfsspec.core.IPFSFileSystem(timeout=100)

cid = "bafybeief7tmoarwmd26b2petx7crtvdnz6ucccek5wpwxwdvfydanfukna"
res = fs._gw_apipost("ls", arg=cid)
links = res["Objects"][0]["Links"]

fs.ls(cid)

I will post up an MR with a fix shortly.