Get directory hash from filestore

I add a really huge directory to ipfs with command:
ipfs add --nocopy -r /root/.ipfs/my_super_huge_mounted_folder

Then I FORGET the hash of that folder.
What now?
(How to get access to the hash of that folder?)

The command:
ipfs filestore ls
gives some hashes which I believe are the hashes of segments of each file, but nowhere I found a hash of a directory.

Put it in mfs after adding ipfs files cp /ipfs/<cid> /the-thing-I-just-added .

You can always see the hash with ipfs files stat /the-thing-I-just-added.

You could also potentially find out the older hash with ipfs pin ls --type=recursive.

1 Like

I was kind of curious what the overhead of putting something into MFS is.

I don’t think there is much overhead. MFS just manages references in a DAG, it does not copy blocks around. Of course an update in a leave on a 1000-level deep MFS DAG may lag a bit.

I am not so advanced user. Can you help a little bit more?

  • Do you propose to drop filestore for mfs?

  • Is there a guarantee that my files will not duplicated (filestore guarantees that).

  • I forget the hash of root folder added in IPFS. So what is that command which you propose to me?
    ipfs files cp /ipfs/<cid> /the-thing-I-just-added

  • My 10TB data are in folder:
    what you prefer.
    So, how can I use mfs without duplication of data?


No, you need to put it on MFS after you do your regular add. That way you can give a name to what you added (and modify the content as needed). See ipfs files --help for info about MFS in general.

So If I forget the root folder Qm... I must do the following:

  • Stop ipfs daemon
  • Delete /root/.ipfs folder
  • ipfs init
  • ipfs config --json Experimental.FilestoreEnabled true
  • ipfs daemon &
  • ipfs add --nocopy -r /root/.ipfs/nas/folder1/shared_folder and get the e.g. Qm1234567...
  • ipfs files cp ipfs/Qm1234567...... /shared_folder

Now I cannot forget the root folder’s Qm... because I always can run:
ipfs files stat /shared_folder
which gives me the Qm... of root folder.
Also I can run:
ipfs files stat /shared_folder/a_file_or_folder
to get the corresponding Qm...