Skip to content
Snippets Groups Projects
Commit 238e0c24 authored by Philip ABBET's avatar Philip ABBET
Browse files

Bugfix: hash.hashFileContents() crash for huge files (> free memory size)

parent 8fcb4366
No related branches found
No related tags found
No related merge requests found
...@@ -112,4 +112,8 @@ def hashFileContents(path): ...@@ -112,4 +112,8 @@ def hashFileContents(path):
"""Hashes the file contents using :py:func:`hashlib.sha256`.""" """Hashes the file contents using :py:func:`hashlib.sha256`."""
with open(path, 'rb') as f: with open(path, 'rb') as f:
return hashlib.sha256(f.read()).hexdigest() sha256 = hashlib.sha256()
for chunk in iter(lambda: f.read(sha256.block_size * 1000), b''):
sha256.update(chunk)
return sha256.hexdigest()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment