From af25c2cd003992ec1d09686f7b4a716769467821 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sun, 24 Aug 2025 23:45:57 +0300 Subject: [PATCH] Feat(check-file-*): Do not stop on errors --- check-file-hashes | 12 +++++++----- check-file-sizes | 9 ++++++--- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/check-file-hashes b/check-file-hashes index df48f69..1327a59 100755 --- a/check-file-hashes +++ b/check-file-hashes @@ -46,18 +46,20 @@ def check_block_hash(block_no: int) -> None: print(' block %d: Ok' % block_no) block = b'' else: - sys.exit(' block %d: Error, digest does not match' - % block_no) + print(' block %d: Error, digest does not match' % block_no) def check_file_hash(path: bytes) -> None: global block full_path = os.path.join(root_dir, path) if not os.path.exists(full_path): - sys.exit('Error: file does not exist: "%s"' % full_path.decode()) + print('Error: file does not exist: "%s"' % full_path.decode(), + file=sys.stderr) + return if not os.path.isfile(full_path): - sys.exit('Error: name is not a regular file: "%s"' - % full_path.decode()) + print('Error: name is not a regular file: "%s"' % full_path.decode(), + file=sys.stderr) + return block_no = 0 print('File "%s"' % full_path.decode()) with open(full_path, 'rb') as fp: diff --git a/check-file-sizes b/check-file-sizes index ab61e23..b429ddf 100755 --- a/check-file-sizes +++ b/check-file-sizes @@ -28,10 +28,13 @@ root_dir = os.path.abspath(data_directory).encode() def check_file_size(path: bytes, size: int) -> None: full_path = os.path.join(root_dir, path) if not os.path.exists(full_path): - sys.exit('Error: file does not exist: "%s"' % full_path.decode()) + print('Error: file does not exist: "%s"' % full_path.decode(), + file=sys.stderr) + return if not os.path.isfile(full_path): - sys.exit('Error: name is not a regular file: "%s"' - % full_path.decode()) + print('Error: name is not a regular file: "%s"' % full_path.decode(), + file=sys.stderr) + return file_size = os.path.getsize(full_path) if file_size == size: print('File Ok: "%s", size %d' % (full_path.decode(), size)) -- 2.39.5