Blocks, direct, recursive, indirect....oh my!

I’m looking for a clarification of pin types and behavior. The docs mentions direct, recursive, and indirect in reference to blocks and the CLI refers to objects. I’m just a little confused. So if I pin an object, say a file, is the object direct pinned and the child blocks indirectly pinned? What gets a recursive pin? Does the root object get a recursive pin and all the child objects get indirect pins or is everything under the root get a recursive pin and child blocks indirect?

If you have a direct pin and it that is then recursively pinned does the recursive pin get clobbered by the recursive pin or does it now have two pins, one recursive and one direct? In that case of a preexisting direct pin that is then pinned recursively, if you now remove the recursive pin is that file now unpinned?

Is there a way to discover the recursive pin that is causing the indirect pin?

No the file is recursively pinned and the descendant blocks are indirectly pinned.

Note: descendant ~= childs, except child blocks is a direct link from a parrent to a child. Descendant include childs of childs, childs of childs of childs, …

The root block gets recursive, all descendants gets indirect.

Direct pins just pin one block, without caring for anything else.

IPFS runs a touching GC for the blocks, so all pin types are runned and the most powerfull one is kept.
So if a block is pinned twice, once as direct and once as indirect, you store one copy only.
Unpinning the recursive root will remove the indirect status, however the direct status will stay on.

I don’t know of any, that info would be really hard to get infact, due to the touching nature of the GC.
Even if refcounting become a thing, that still would be hard.

So it seems like most of the time it’s going to be a recursive pin + indirectly pinned. I’m wondering when you would ever directly pin a single block unless it was just a really small file inlined with a single block. Also why make the distinction between direct and recursive and not just make a single block a recursive with no descendants?

direct pinning is an advanced feature, I don’t see why you would use it unless you do some IPLD trickery magic and need this kind of advanced feature.

TLDR just use recursive it’s fine