Make config persistence robust and history DB concurrency-safe
- Config saves are atomic (temp file + fsync + os.replace); a crash or power loss mid-write no longer truncates the file, which previously caused a silent reset to defaults on next launch. - Stored config is merged over a deep copy of the defaults: keys added in newer versions resolve properly instead of returning None, and the nested cached_versions dict is no longer shared with (and mutated on) the class-level default dict. - History SQLite connection enables WAL and a 5s busy timeout so the download thread can record entries while the history dialog reads without "database is locked" errors. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -72,6 +72,10 @@ class HistoryManager:
|
||||
if cls._connection is None:
|
||||
cls._connection = sqlite3.connect(cls._db_file, check_same_thread=False)
|
||||
cls._connection.row_factory = sqlite3.Row
|
||||
# WAL lets the download thread write while the history
|
||||
# dialog reads; busy_timeout avoids "database is locked"
|
||||
cls._connection.execute("PRAGMA journal_mode=WAL")
|
||||
cls._connection.execute("PRAGMA busy_timeout=5000")
|
||||
|
||||
cursor = cls._connection.cursor()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user