From 9cc5d071d035ed6e6d384f2a1f62827763868df7 Mon Sep 17 00:00:00 2001 From: derrod Date: Wed, 20 May 2020 12:03:44 +0200 Subject: [PATCH] [utils] Return hashes from validate_files --- legendary/utils/lfs.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/legendary/utils/lfs.py b/legendary/utils/lfs.py index 098503e..ad73420 100644 --- a/legendary/utils/lfs.py +++ b/legendary/utils/lfs.py @@ -47,7 +47,7 @@ def validate_files(base_path: str, filelist: List[tuple], hash_type='sha1') -> I # logger.debug(f'Checking "{file_path}"...') if not os.path.exists(full_path): - yield VerifyResult.FILE_MISSING, file_path + yield VerifyResult.FILE_MISSING, file_path, '' continue with open(full_path, 'rb') as f: @@ -55,10 +55,11 @@ def validate_files(base_path: str, filelist: List[tuple], hash_type='sha1') -> I while chunk := f.read(8192): real_file_hash.update(chunk) - if file_hash != real_file_hash.hexdigest(): - yield VerifyResult.HASH_MISMATCH, file_path + result_hash = real_file_hash.hexdigest() + if file_hash != result_hash: + yield VerifyResult.HASH_MISMATCH, file_path, result_hash else: - yield VerifyResult.HASH_MATCH, file_path + yield VerifyResult.HASH_MATCH, file_path, result_hash def clean_filename(filename):