'How can one list all of the currently pinned files for an IPFS instance?
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?
Solution 1:[1]
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | dividebyzero |