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

This commit is contained in:
LightningDragon 2023-10-25 09:15:34 -06:00 committed by GitHub
parent 72f6fc6923
commit 0ced78fdfa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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