Skip to main content

Module repo

Module repo 

Source
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 state and last_error (does not touch counters).