Commit 238e0c24 authored by Philip ABBET's avatar Philip ABBET

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

parent 8fcb4366
......@@ -112,4 +112,8 @@ def hashFileContents(path):
"""Hashes the file contents using :py:func:`hashlib.sha256`."""
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()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment