mirror of
https://github.com/scottlamb/moonfire-nvr.git
synced 2025-11-26 12:36:14 -05:00
extend recording_playback with an open_id
As noted in schema.sql, this can be used for disambiguation. It also may be useful in diagnosing data integrity problems. Also, sneak in a couple minor improvements: better diagnostics in a couple places, fix to 1->2 upgrade procedure.
This commit is contained in:
@@ -47,8 +47,8 @@ const INSERT_RECORDING_SQL: &'static str = r#"
|
||||
"#;
|
||||
|
||||
const INSERT_RECORDING_PLAYBACK_SQL: &'static str = r#"
|
||||
insert into recording_playback (composite_id, sample_file_sha1, video_index)
|
||||
values (:composite_id, :sample_file_sha1, :video_index)
|
||||
insert into recording_playback (composite_id, open_id, sample_file_sha1, video_index)
|
||||
values (:composite_id, :open_id, :sample_file_sha1, :video_index)
|
||||
"#;
|
||||
|
||||
const STREAM_MIN_START_SQL: &'static str = r#"
|
||||
@@ -73,7 +73,7 @@ const STREAM_MAX_START_SQL: &'static str = r#"
|
||||
"#;
|
||||
|
||||
/// Inserts the specified recording (for from `try_flush` only).
|
||||
pub(crate) fn insert_recording(tx: &rusqlite::Transaction, id: CompositeId,
|
||||
pub(crate) fn insert_recording(tx: &rusqlite::Transaction, o: &db::Open, id: CompositeId,
|
||||
r: &db::RecordingToInsert) -> Result<(), Error> {
|
||||
if r.time.end < r.time.start {
|
||||
bail!("end time {} must be >= start time {}", r.time.end, r.time.start);
|
||||
@@ -98,6 +98,7 @@ pub(crate) fn insert_recording(tx: &rusqlite::Transaction, id: CompositeId,
|
||||
let sha1 = &r.sample_file_sha1[..];
|
||||
stmt.execute_named(&[
|
||||
(":composite_id", &id.0),
|
||||
(":open_id", &o.id),
|
||||
(":sample_file_sha1", &sha1),
|
||||
(":video_index", &r.video_index),
|
||||
])?;
|
||||
|
||||
Reference in New Issue
Block a user