Revert "Replace hashlib.sha256 with hashlib.file_digest so we don't need to load entire files into ram before hashing them. (#4383)"

This reverts commit 0ced78fdfa.
This commit is contained in:
oobabooga 2024-02-26 05:54:33 -08:00
parent 4164e29416
commit 830168d3d4

View File

@ -262,7 +262,8 @@ class ModelDownloader:
continue continue
with open(output_folder / sha256[i][0], "rb") as f: with open(output_folder / sha256[i][0], "rb") as f:
file_hash = hashlib.file_digest(f, "sha256").hexdigest() bytes = f.read()
file_hash = hashlib.sha256(bytes).hexdigest()
if file_hash != sha256[i][1]: if file_hash != sha256[i][1]:
print(f'Checksum failed: {sha256[i][0]} {sha256[i][1]}') print(f'Checksum failed: {sha256[i][0]} {sha256[i][1]}')
validated = False validated = False