There are two concepts in IPFS, the connection of which is not very clear to me: IPFS pin and IPFS MFS.
As I understand it, ipfs pin
allows you to keep content on your node, protecting it from being automatically removed by the garbage collector. In this case, if I add content by myself using ipfs add <file>
, then it will be automatically pinned and then it can be unpinned and removed only manually.
IPFS MFS, on the other hand, allows objects to be manipulated as if they were in the file system. For example, I can copy a specific external object to MFS using ipfs files cp <id> <name>
. After that, I can find out its ID using ipfs files stat <name>
.
The questions are:
ipfs pin ls
?ipfs add <file>
, then add it to MFS using ipfs files cp <id> <name>
, and then unpin it using ipfs pin rm <id>
?these pretty good questions! Answering them separately
- Are the files in MFS protected from being removed by garbage collector?
They are not by default Pinned. You will need to pin those files as well if you want them tracked by the Pinner. You can do a ipfs files stat /somePath
, get the hash and then pin that hash.
The part where it gets confusing is that GC will do a "best effort" pinning, in which files that are accessed by the root of the MFS DAG will not be GC as well.
Example:
If you want to protect the previous, you can use the Pin API.
- If protected, then why are they not displayed in
ipfs pin ls
?
As answered on 1., you will need to pin them manually to see it being tracked by the pinning system.
- Will the data be saved if I add it using
ipfs add <file>
, then add it to MFS usingipfs files cp <id> <name>
, and then unpin it usingipfs pin rm <id>
?
Perhaps you get the gist by now. To clarify:
- Is IPFS MFS a more reliable way to work with data?
It is a more familiar way as you get the regular directory structures and Unix like API to operate over files. It handles the graph manipulations for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With