MCPcopy Create free account
hub / github.com/modelscope/modelscope / compute_hash

Function compute_hash

modelscope/hub/utils/utils.py:248–258  ·  view source on GitHub ↗
(file_path)

Source from the content-addressed store, hash-verified

246
247
248def compute_hash(file_path):
249 # 16MB buffer for large file hash computation
250 BUFFER_SIZE = 1024 * 1024 * 16
251 sha256_hash = hashlib.sha256()
252 with open(file_path, 'rb') as f:
253 while True:
254 data = f.read(BUFFER_SIZE)
255 if not data:
256 break
257 sha256_hash.update(data)
258 return sha256_hash.hexdigest()
259
260
261def file_integrity_validation(file_path, expected_sha256) -> bool:

Callers 3

existsMethod · 0.90

Calls 2

readMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…