Skip to main content

set_segments_locked

Function set_segments_locked 

Source
pub async fn set_segments_locked(
    pool: &SqlitePool,
    ids: &[String],
    locked: bool,
)
Expand description

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.