Add local settings management
Add cellular-first ntfy delivery with WiFi fallback and safe SIM868 HTTP header framing. Co-authored-by: Copilot <[email protected]>
This commit is contained in:
@@ -405,6 +405,24 @@ def set_setting(key, value):
|
||||
conn.commit()
|
||||
|
||||
|
||||
def set_settings(settings):
|
||||
"""Persist a validated group of settings atomically."""
|
||||
conn = get_conn()
|
||||
if conn is None:
|
||||
raise RuntimeError("Settings database is not available.")
|
||||
with _conn_lock:
|
||||
try:
|
||||
conn.executemany(
|
||||
"INSERT INTO settings (key, value) VALUES (?, ?) "
|
||||
"ON CONFLICT(key) DO UPDATE SET value = excluded.value",
|
||||
settings.items(),
|
||||
)
|
||||
conn.commit()
|
||||
except sqlite3.Error:
|
||||
conn.rollback()
|
||||
raise
|
||||
|
||||
|
||||
def get_alert_states():
|
||||
conn = get_conn()
|
||||
if conn is None:
|
||||
|
||||
Reference in New Issue
Block a user