MCPcopy
hub / github.com/wkentaro/gdown / _assert_filehash

Function _assert_filehash

gdown/cached_download.py:155–168  ·  view source on GitHub ↗
(path: str, hash: str, quiet: bool = False)

Source from the content-addressed store, hash-verified

153
154
155def _assert_filehash(path: str, hash: str, quiet: bool = False) -> None:
156 if ":" not in hash:
157 raise ValueError(
158 f"Invalid hash: {hash}. "
159 "Hash must be in the format of {algorithm}:{hash_value}."
160 )
161 algorithm = hash.split(":")[0]
162
163 hash_actual = _compute_filehash(path=path, algorithm=algorithm)
164
165 if hash_actual != hash:
166 raise AssertionError(
167 f"File hash doesn't match:\nactual: {hash_actual}\nexpected: {hash}"
168 )

Callers 2

_test_cli_with_md5Function · 0.90
cached_downloadFunction · 0.85

Calls 1

_compute_filehashFunction · 0.85

Tested by 1

_test_cli_with_md5Function · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…