Expand description
Small shared data-access helpers used by background services and routes.
Functions§
- bump_
reconnect - Increment the reconnect counter, clear pid, and record the last error.
- log_
event - Insert an event into the event log.
- record_
segment_ indexed - Record that a new segment was indexed: bump count, set last_segment_at and observed bitrate.
- set_
running - Mark the recorder process started: set state, pid, and last_started_at.
- set_
segments_ locked - Toggle a transient read-lock on a set of segments so the retention sweeper (which only deletes
locked = 0) won’t remove them while clip/snapshot ffmpeg is reading them — closing the TOCTOU between selecting segments and ffmpeg opening their files. Best-effort: a failure is logged, not fatal (the read still proceeds). Locks are cleared at startup (crate::db::clear_segment_read_locks) so a crash mid-read cannot pin segments forever. - set_
state - Upsert the camera status row, setting
stateandlast_error(does not touch counters).