Given a CID, I want to quickly check if it fully exists locally. In the JS implementation, the blockstore in js-ipfs-repo has a method to check if the CID exist in the store. I’m looking for a similar solution ideally using the js-http-client with go-ipfs.
The closest thing I can come up with is using files.stat with the withLocal option but I assume that this will attempt to retrieve the blocks from the network if they are not available locally.
That would be incredibly useful. In my use case, the nodes may have upwards of 4-10TBs locally and for various reasons (mainly performance), it helps to distinguish local CIDs from remote CIDs to more efficiently decide what operations to perform and in what order.
I’m going to test out pulling the local refs through js-http-client using ipfs.refs.local later today — I’m guessing it’ll work fine but might become an issue as the list grows.
To clarify, will a CID show up in ipfs.refs.local if any or all of its blocks exist locally?
I believe it is a reasonable feature request to extend ipfs refs local [-r] [CID] to take optional CID argument and print it if it is in local repo. If -r is passed, print all local blocks that belong to the root. This would match existing behavior of ipfs refs and ipfs refs -r. Together, they would enable people to calculate how much of data behind CID is stored locally.
Use case: IPFS Companion is bundling webui and importing it to datastore if it is not in it already. To do the check, it needs to list all local CIDs and if there is no match, perform import. Extremely not efficient check if user has a lot of blocks.