@@ -507,24 +507,25 @@ def open_library(self, path: str | Path, is_path_file: bool = False) -> int:
507
507
508
508
except (ujson .JSONDecodeError , FileNotFoundError ):
509
509
logging .info (
510
- "[LIBRARY][WARNING ] Blank/Corrupted Library file found. Searching for Auto Backup..."
510
+ "[LIBRARY][ERROR ] Blank/Corrupted Library file found. Searching for Auto Backup..."
511
511
)
512
512
backup_folder : Path = (
513
513
self ._fix_lib_path (path ) / TS_FOLDER_NAME / BACKUP_FOLDER_NAME
514
514
)
515
- auto_backup : Path = None
516
- dir_obj = os .scandir (backup_folder )
515
+ if backup_folder .exists ():
516
+ auto_backup : Path = None
517
+ dir_obj = os .scandir (backup_folder )
517
518
518
- for backup_file in dir_obj :
519
- if backup_file .is_file () and "ts_library_backup_auto" in str (
520
- backup_file
521
- ):
522
- auto_backup = Path (backup_file )
523
- break
519
+ for backup_file in dir_obj :
520
+ if backup_file .is_file () and "ts_library_backup_auto" in str (
521
+ backup_file
522
+ ):
523
+ auto_backup = Path (backup_file )
524
+ break
524
525
525
- if auto_backup and "ts_library_backup_auto" not in str (path ):
526
- logging .info (f"[LIBRARY] Loading Auto Backup: { auto_backup } " )
527
- return self .open_library (auto_backup , is_path_file = True )
526
+ if auto_backup and "ts_library_backup_auto" not in str (path ):
527
+ logging .info (f"[LIBRARY] Loading Auto Backup: { auto_backup } " )
528
+ return self .open_library (auto_backup , is_path_file = True )
528
529
529
530
else :
530
531
self .library_dir = self ._fix_lib_path (path )
@@ -727,7 +728,7 @@ def open_library(self, path: str | Path, is_path_file: bool = False) -> int:
727
728
c = Collation (
728
729
id = id ,
729
730
title = title ,
730
- e_ids_and_pages = e_ids_and_pages , # type: ignore
731
+ e_ids_and_pages = e_ids_and_pages ,
731
732
sort_order = sort_order ,
732
733
cover_id = cover_id ,
733
734
)
0 commit comments