minor improvment
small change so that the available ram is checked and not the total ram
This commit is contained in:
parent
0a6d364c5a
commit
24317a510e
1 changed files with 3 additions and 3 deletions
|
@ -3,11 +3,11 @@ import hashlib
|
||||||
import psutil
|
import psutil
|
||||||
|
|
||||||
def sha256sum(file):
|
def sha256sum(file):
|
||||||
# Check if system has enough RAM to read the file at once
|
# Check if system has enough free RAM to read the file at once
|
||||||
file_size = os.path.getsize(file)
|
file_size = os.path.getsize(file)
|
||||||
total_memory = psutil.virtual_memory().total
|
available_memory = psutil.virtual_memory().available
|
||||||
|
|
||||||
if file_size < total_memory:
|
if file_size < available_memory:
|
||||||
# Read the file at once
|
# Read the file at once
|
||||||
with open(file, "rb") as f:
|
with open(file, "rb") as f:
|
||||||
file_hash = hashlib.sha256(f.read())
|
file_hash = hashlib.sha256(f.read())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue