Is there a easy way to list all files recursively given one hash?

I can recursively run ipfs ls but wonder if there is a ready-to-use API for it?

Another way I can think of is to list all hashes first with ipfs refs -r and filter out directories later. However refs command only lists cids, no file type. I tried to figure out how to tell if a hash is file or directory but didn’t find any easy ways. There is a post here Way to identify if a hash is a directory or a file but the solution looks too hacky and I’m not sure if it’s still working or not.

1 Like

Anyone to help? I’m using js-ipfs.

1 Like

I search for the same, without success.

It seems that we must write code for it.

But this is not so efficient.
Python code, must call ‘ipfs’ as times as the number of subdirectories.
This is VERY inefficient if you want e.g. synchronization every 30 minutes.
Because loading of an external big binary involved many times.

Instead you can get ride of ‘ipfs’ for that process and keep your log of filenames, hashes, sizes and timestamp of previous script run. So you have duplication of file structure metadata.