Skip to content

Commit c75e8c2

Browse files
Add robust error handling and logging for table creation
1 parent 51e4e84 commit c75e8c2

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

CONTRIBUTORS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ Copyright (C) 2024-2025 Calibre-Web Automated contributors
293293
- whilenot-dev (1 commits)
294294
- Wolfenk (1 commits)
295295
- wolviex (1 commits)
296-
- Wouter Dijk (anon) (1 commits)
296+
- wouterdijk-cpu (1 commits)
297297
- WouterKoch (1 commits)
298298
- wuwei-12138 (1 commits)
299299
- xybydy (1 commits)
@@ -303,7 +303,7 @@ Copyright (C) 2024-2025 Calibre-Web Automated contributors
303303
- zhiyue (1 commits)
304304
# Fork Contributors (crocodilestick/calibre-web-automated)
305305

306-
- crocodilestick (782 commits)
306+
- crocodilestick (783 commits)
307307
- jmarmstrong1207 (73 commits)
308308
- demitrix (30 commits)
309309
- sirwolfgang (29 commits)

cps/db.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -738,11 +738,20 @@ def setup_db(cls, config_calibre_dir, app_db_path):
738738

739739
# Ensure progress syncing tables exist in metadata.db (book checksums)
740740
# Use a direct connection to ensure the table is created in the file, not in-memory
741-
from .progress_syncing.models import ensure_calibre_db_tables
742741
try:
743-
with sqlite3.connect(dbpath, timeout=30) as direct_conn:
744-
ensure_calibre_db_tables(direct_conn)
742+
# Import inside try block to handle potential circular imports or missing modules gracefully
743+
from .progress_syncing.models import ensure_calibre_db_tables
744+
745+
# Verify dbpath exists
746+
if os.path.exists(dbpath):
747+
with sqlite3.connect(dbpath, timeout=30) as direct_conn:
748+
ensure_calibre_db_tables(direct_conn)
749+
else:
750+
log.error(f"Cannot ensure tables: metadata.db not found at {dbpath}")
745751
except Exception as e:
752+
# Log to both app log and stderr to ensure visibility in Docker logs
753+
import sys
754+
sys.stderr.write(f"ERROR: Failed to ensure progress syncing tables: {e}\n")
746755
log.error(f"Failed to ensure progress syncing tables: {e}")
747756

748757
cls._init = True

0 commit comments

Comments
 (0)