minor improvment

small change so that the available ram is checked and not the total ram
This commit is contained in:
KASR 2023-04-27 16:51:52 +02:00 committed by GitHub
parent 0a6d364c5a
commit 24317a510e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,11 +3,11 @@ import hashlib
import psutil
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)
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
with open(file, "rb") as f:
file_hash = hashlib.sha256(f.read())