File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ class Settings(BaseSettings):
1919 display_subtitle : Optional [bool ] = None
2020 UA_convert_jxl : str = 'Android'
2121 UA_convert_all : str = r'\b\B' # default: match nothing
22+ skip_scan_error : bool = False
2223
2324settings = Settings ()
2425
Original file line number Diff line number Diff line change 55import copy
66import hashlib
77import time
8+ import traceback
89from pathlib import Path
910from pprint import pformat
1011
3536
3637
3738def scan (paths ):
39+ exceptions = Exception if settings .skip_scan_error else ()
40+ errors = {}
3841 with Session (engine ) as db :
3942 try :
4043 for p in paths :
4144 checkpoint = db .begin_nested ()
4245 try :
46+ name = None
4347 p = Path (os .path .relpath (p , settings .content ))
4448 if p .is_relative_to ('thumb' ):
4549 continue
@@ -59,10 +63,11 @@ def scan(paths):
5963 prev_scanners = []
6064 for scanner , name in scanners :
6165 prev_metadata = copy .deepcopy (metadata )
62- if scanner .scan (real_path , archive_id , metadata , prev_scanners ):
66+ if scanner .scan (path = real_path , id = archive_id , metadata = metadata , prev_scanners = prev_scanners ):
6367 prev_scanners .append (name )
6468 else :
6569 metadata = prev_metadata
70+ name = 'post_process'
6671 if not prev_scanners :
6772 continue
6873 if not any (tag .startswith ("date_added:" ) for tag in metadata ["tags" ]):
@@ -91,11 +96,16 @@ def scan(paths):
9196 a .id = metadata ["id" ]
9297 db .add (a )
9398 checkpoint .commit ()
99+ except exceptions :
100+ logger .error (traceback .format_exc ())
101+ errors [str (p )] = name
94102 finally :
95103 if checkpoint .is_active :
96104 checkpoint .rollback ()
97105 finally :
98106 db .commit ()
107+ if settings .skip_scan_error and errors :
108+ logger .error ('Processing failed while scanning the following files:\n %s' , pformat (errors ))
99109
100110def get_files_inuse ():
101111 ret = set ()
You can’t perform that action at this time.
0 commit comments