Fix SQLite WAL mode error on FUSE filesystems

WAL mode can fail on filesystems like mergerfs that don't fully support
memory-mapped files. Add graceful fallback to DELETE journal mode.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
rob 2026-01-01 05:50:03 -04:00
parent 55d46d1f61
commit d85eb36a72
1 changed files with 7 additions and 1 deletions

View File

@ -245,7 +245,13 @@ def connect_db(path: Path | None = None) -> sqlite3.Connection:
ensure_db_directory(db_path)
conn = sqlite3.connect(db_path)
conn.row_factory = sqlite3.Row
# WAL mode provides better concurrency but may not work on all filesystems
# (e.g., some FUSE filesystems like mergerfs). Fall back gracefully.
try:
conn.execute("PRAGMA journal_mode=WAL;")
except sqlite3.OperationalError:
# Fall back to DELETE journal mode which works everywhere
conn.execute("PRAGMA journal_mode=DELETE;")
conn.execute("PRAGMA foreign_keys=ON;")
return conn