fix: audit logs never persisted + firmware-cache permission denied

Two bugs fixed:

1. audit_service.py: log_action() inserted into audit_logs using the
   caller's DB session but never committed. Any router that called
   db.commit() before log_action() (firmware, devices, config_editor,
   alerts, certificates) had its audit rows silently rolled back when
   the request session closed.
   Fix: log_action now opens its own AdminAsyncSessionLocal and self-
   commits, making audit persistence independent of the caller's
   transaction. The 'db' parameter is kept for backward compat but
   unused. Affects 5 routers (firmware, devices, config_editor,
   alerts, certificates).

2. docker-compose.override.yml: /data/firmware-cache had no volume
   mount so the directory didn't exist in the container, causing
   firmware downloads to fail with Permission denied.
   Fix: bind-mount docker-data/firmware-cache:/data/firmware-cache
   so firmware images survive container restarts.
This commit is contained in:
Cog
2026-03-11 23:02:36 -05:00
committed by Jason Staack
parent 21b8ce029f
commit 6b22741f54
2 changed files with 39 additions and 24 deletions

View File

@@ -47,6 +47,7 @@ services:
volumes:
- ./backend:/app
- ./docker-data/git-store:/data/git-store
- ./docker-data/firmware-cache:/data/firmware-cache
- ./docker-data/wireguard:/data/wireguard
depends_on:
postgres: