]> git.phdru.name Git - bittorrent.git/commitdiff
Feat(check-file-*): Do not stop on errors
authorOleg Broytman <phd@phdru.name>
Sun, 24 Aug 2025 20:45:57 +0000 (23:45 +0300)
committerOleg Broytman <phd@phdru.name>
Mon, 1 Sep 2025 16:28:24 +0000 (19:28 +0300)
check-file-hashes
check-file-sizes

index df48f6915d219bb0659088ec41399318c7b6cabe..1327a5980552cfb24e7c049d2c9f8de57a19f1e6 100755 (executable)
@@ -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:
index ab61e238ae723dda84729ffe243abfe24b76e307..b429ddfc99b5947174a43093a35e59dbedfda72a 100755 (executable)
@@ -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))