ipfs-shipyard / cohosting

A set of light tools and conventions for cohosting public websites and files on IPFS
Creative Commons Zero v1.0 Universal
25 stars 1 forks source link

ipfs files cp does not ensure recursive content #4

Closed hacdias closed 5 years ago

hacdias commented 5 years ago

While working on cohosting.sh and ipfs-cohost, I noticed ipfs files cp does not ensure recursive content. It just links the hash to a certain place in MFS and only fetches it if the user actually goes there.

Even though having a directory on MFS prevents it from being garbage collected, it does not get recursively fetched when copying for the first time.

/cc @lidel @autonome

hacdias commented 5 years ago

An alternative way, for now, could be to first pin to make sure we have all the contents in the repo. Is there any command similar to pin that fetches recursively something to the repo but does not pin?

lidel commented 5 years ago

@hacdias We should avoid using low level pins here. I believe ipfs refs --recursive <CID> is what you want. It lists all children of the root CID, which has a side-effect of preloading all content to the local repo :)

hacdias commented 5 years ago

A way to solve this, for now, is to call ipfs get $cid and ignore the results or ipfs refs -r $cid before copying to MFS. That way we can get everything block.

hacdias commented 5 years ago

Oh, sorry. Replied and what you said hasn't been loaded before. I'll PR.

lidel commented 5 years ago

I created https://github.com/ipfs-shipyard/cohosting/issues/6 to discuss idea of "Lazy cohosting" that takes advantage of how ipfs files cp works.