From e7f451d4f6d303058804966fb71e37d147ec0ef8 Mon Sep 17 00:00:00 2001 From: vangef Date: Fri, 3 Mar 2023 13:48:56 +0000 Subject: [PATCH] check empty file hash - do not include empty files in hash list --- utils/inspector.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/utils/inspector.py b/utils/inspector.py index e52ad22..ab9d716 100644 --- a/utils/inspector.py +++ b/utils/inspector.py @@ -31,9 +31,10 @@ def get_hashes_in_dir(dir_path: str, excluded_filenames: list = []) -> list: # for filename in files: if filename.lower() not in excluded_filenames: # convert to lowercase for comparison with excluded files & do not hash if in the excluded list filepath = os.path.join(subdir, filename) - with open(filepath, 'rb') as f: + with open(filepath, 'rb') as f: filehash = hashlib.sha256(f.read()).hexdigest() - hash_list.append({ 'filepath': filepath, 'filename': filename, 'sha256 hash': filehash}) + if filehash != 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855': # do not include hashes of empty files + hash_list.append({ 'filepath': filepath, 'filename': filename, 'sha256 hash': filehash}) return hash_list