fix: WAL mode on SQLite + longer timeout to prevent database locked errors
Deploy via Portainer / deploy (push) Successful in 0s

This commit is contained in:
Jo
2026-07-07 13:33:28 +02:00
parent b55edceff8
commit 522a0c5e83
+6 -2
View File
@@ -75,8 +75,10 @@ def require_login_global():
return redirect(url_for('login'))
def get_db():
conn = sqlite3.connect(DATABASE, timeout=10)
conn = sqlite3.connect(DATABASE, timeout=30)
conn.row_factory = sqlite3.Row
conn.execute('PRAGMA journal_mode=WAL')
conn.execute('PRAGMA synchronous=NORMAL')
return conn
def init_db():
@@ -2038,8 +2040,10 @@ def _ha_sync_once():
states = _ha_fetch_all_states(ha_url, ha_token)
if not states:
return
conn = sqlite3.connect(DATABASE, timeout=15)
# Ouvrir la connexion d'écriture APRÈS l'appel HTTP (qui peut être long)
conn = sqlite3.connect(DATABASE, timeout=30)
conn.row_factory = sqlite3.Row
conn.execute('PRAGMA journal_mode=WAL')
printers = conn.execute(
"SELECT id, name, ha_entity_prefix FROM printers "
"WHERE ha_entity_prefix IS NOT NULL AND ha_entity_prefix != ''"