5

According to https://docs.ipfs.io/guides/concepts/pinning/ , running the command ipfs add hello.txt apparently "pins" the file "hello.txt", yet why don't I see the file listed afterwards when I run the command ipfs files ls? It only lists files I added with the IPFS desktop app. Why is "hello.txt" not in the list now?

Also, I found a list of so-called "pinned" objects, by running the command ipfs pin ls, however none of the CID's that show up there correspond to "hello.txt", or even any of the previously mentioned files added using the IPFS desktop app.

How does one actually manage pinned files?

Joncom
  • 1,985
  • 1
  • 18
  • 29

2 Answers2

8

cool to see some questions about IPFS pop up here! :)

So, there are two different things:

  • Pins
  • Files/Folders (Called MFS)

They both overlap heavily, but it's best to describe that the MFS is basically a locally alterable filesystem with a mapping of 'objects' as files and folders.

You have a root ( / ) in your local IPFS client, where you can put files and folders.

For example you can add a folder recursively:

ipfs add -r --recursive /path/to/folder

You get a CID (content ID) back. This content ID represents the folder, all its files and all the file structure as a non-modifiable data structure.

This folder can be mapped to a name in your local root:

ipfs files cp /ipfs/<CID> /<foldername>

A ipfs files ls will now show this folder by name, while an ipfs pin ls --type=recursive will show the content-ID as pinned.

If you use the (Web)GUI, files will show up under the 'files' tab, while the pins show up under the 'pins' tab.


Just a side note, you don't have to pin a file or folder stored in your MFS, everything stored there will be permanently available.

If you going to change the folders, subfolders, files, etc in your MFS, the folder will get a different Content-ID and your pin will still make sure the old version is held on your client.

So if you add another file to your folder, by something like cat /path/to/file | ipfs files write --create /folder/<newfilename>, the CID of your folder will be different.

Compare ipfs files stat --hash /folder and afterwards again.

Hope I didn't fully confuse you :D

Best regards

Ruben

dividebyzero
  • 2,190
  • 1
  • 21
  • 33
  • Ah, didn't realize that "pinned files" and files in the "files folder" (MFS) were two different systems that get managed separately. Makes more sense now. – Joncom Mar 30 '20 at 19:02
2

Answer:
ipfs pin ls --type recursive

It's simple. Just run that command.

Some further notes: the type can be "direct", "recursive", "indirect", and "all". I ran these commands with these results ("Error: context canceled" means that I canceled the command with ctrl+c):

  • ipfs pin ls --type all - took too long, "Error: context canceled"
  • ipfs pin ls --type direct - took too long, "Error: context canceled"
  • ipfs pin ls --type indirect - took too long, "Error: context canceled"
  • ipfs pin ls --type recursive - worked, showed multiple, probably all, pins of mine

I don't really know what types other than recursive mean. You can read about them from the output of this command: ipfs pin ls --help.

Rublacava
  • 414
  • 1
  • 4
  • 16