alper
alper

Reputation: 3410

How to check is the given <ipfs_hash> is already fully downloaded or not?

First when I run ipfs --offline block stat <ipfs_hash> and if the hash does not locally exist I get following message: Error: blockservice: key not found.

How can I resolve this in order to detect if the asked hashed is fully downloaded or not?


I can do something like ipfs refs local | grep <hash> , but I don't want to keep fetch all the hashes and it will be slower when there is hundreds of hashes exist.

Related: https://discuss.ipfs.io/t/how-to-check-is-the-given-ipfs-hash-and-its-linked-hashes-already-downloaded-or-not/7588

Upvotes: 0

Views: 1538

Answers (1)

alper
alper

Reputation: 3410

ipfs files stat --with-local --size <path> returns the downloaded percentage of the requested ipfs hash. If its 100.00% than we can verify that its fully downloaded into local ipfs repo.

ipfs files stat <path> - Display file status.

--with-local  bool   - Compute the amount of the dag that is local, and if possible the total size.
--size        bool   - Print only size. Implies '--format=<cumulsize>'. Conflicts with other format options. ```

$ hash="QmPHTrNR9yQYRU4Me4nSG5giZVxb4zTtEe1aZshgByFCFS"
$ ipfs files stat --with-local --size /ipfs/$hash
407624015
Local: 408 MB of 408 MB (100.00%)

Upvotes: 0

Related Questions