mirror of
https://github.com/scottlamb/moonfire-nvr.git
synced 2025-03-30 17:23:43 -04:00
parent
dd4a901adb
commit
4e77a26410
@ -11,6 +11,8 @@ Each release is tagged in Git and on the Docker repository
|
|||||||
* fix [#146](https://github.com/scottlamb/moonfire-nvr/issues/146): "init
|
* fix [#146](https://github.com/scottlamb/moonfire-nvr/issues/146): "init
|
||||||
segment fetch error" when browsers have cached data from `v0.6.4` and
|
segment fetch error" when browsers have cached data from `v0.6.4` and
|
||||||
before.
|
before.
|
||||||
|
* fix [#147](https://github.com/scottlamb/moonfire-nvr/issues/147): confusing
|
||||||
|
`nvr init` failures when using very old versions of SQLite.
|
||||||
|
|
||||||
## `v0.6.5` (2021-08-13)
|
## `v0.6.5` (2021-08-13)
|
||||||
|
|
||||||
|
@ -177,7 +177,9 @@ To build the server, you will need the following C libraries installed:
|
|||||||
timeouts for RTSP. For reliable reconnections on error, it's strongly
|
timeouts for RTSP. For reliable reconnections on error, it's strongly
|
||||||
recommended to use ffmpeg library versions >= 55.1.101.
|
recommended to use ffmpeg library versions >= 55.1.101.
|
||||||
|
|
||||||
* [SQLite3](https://www.sqlite.org/).
|
* [SQLite3](https://www.sqlite.org/), at least version 3.14.0.
|
||||||
|
(You can skip this if you compile with `--features=bundled` and
|
||||||
|
don't mind the `moonfire-nvr sql` command not working.)
|
||||||
|
|
||||||
* [`ncursesw`](https://www.gnu.org/software/ncurses/), the UTF-8 version of
|
* [`ncursesw`](https://www.gnu.org/software/ncurses/), the UTF-8 version of
|
||||||
the `ncurses` library.
|
the `ncurses` library.
|
||||||
|
@ -35,7 +35,7 @@ use crate::schema;
|
|||||||
use crate::signal;
|
use crate::signal;
|
||||||
use base::clock::{self, Clocks};
|
use base::clock::{self, Clocks};
|
||||||
use base::strutil::encode_size;
|
use base::strutil::encode_size;
|
||||||
use failure::{bail, format_err, Error};
|
use failure::{bail, format_err, Error, ResultExt};
|
||||||
use fnv::{FnvHashMap, FnvHashSet};
|
use fnv::{FnvHashMap, FnvHashSet};
|
||||||
use hashlink::LinkedHashMap;
|
use hashlink::LinkedHashMap;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
@ -2117,13 +2117,27 @@ pub(crate) fn set_integrity_pragmas(conn: &mut rusqlite::Connection) -> Result<(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn check_sqlite_version() -> Result<(), Error> {
|
||||||
|
// SQLite version 3.14.0 introduced the "without rowid" syntax used in the schema.
|
||||||
|
// https://www.sqlite.org/vtab.html#worid
|
||||||
|
if rusqlite::version_number() < 3014000 {
|
||||||
|
bail!(
|
||||||
|
"SQLite version {} is too old; need at least 3.14.0",
|
||||||
|
rusqlite::version()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
/// Initializes a database.
|
/// Initializes a database.
|
||||||
/// Note this doesn't set journal options, so that it can be used on in-memory databases for
|
/// Note this doesn't set journal options, so that it can be used on in-memory databases for
|
||||||
/// test code.
|
/// test code.
|
||||||
pub fn init(conn: &mut rusqlite::Connection) -> Result<(), Error> {
|
pub fn init(conn: &mut rusqlite::Connection) -> Result<(), Error> {
|
||||||
|
check_sqlite_version()?;
|
||||||
set_integrity_pragmas(conn)?;
|
set_integrity_pragmas(conn)?;
|
||||||
let tx = conn.transaction()?;
|
let tx = conn.transaction()?;
|
||||||
tx.execute_batch(include_str!("schema.sql"))?;
|
tx.execute_batch(include_str!("schema.sql"))
|
||||||
|
.context("unable to create database schema")?;
|
||||||
{
|
{
|
||||||
let uuid = ::uuid::Uuid::new_v4();
|
let uuid = ::uuid::Uuid::new_v4();
|
||||||
let uuid_bytes = &uuid.as_bytes()[..];
|
let uuid_bytes = &uuid.as_bytes()[..];
|
||||||
@ -2221,6 +2235,7 @@ impl<C: Clocks + Clone> Database<C> {
|
|||||||
mut conn: rusqlite::Connection,
|
mut conn: rusqlite::Connection,
|
||||||
read_write: bool,
|
read_write: bool,
|
||||||
) -> Result<Database<C>, Error> {
|
) -> Result<Database<C>, Error> {
|
||||||
|
check_sqlite_version()?;
|
||||||
set_integrity_pragmas(&mut conn)?;
|
set_integrity_pragmas(&mut conn)?;
|
||||||
check_schema_version(&conn)?;
|
check_schema_version(&conn)?;
|
||||||
|
|
||||||
|
@ -90,6 +90,7 @@ fn upgrade(args: &Args, target_ver: i32, conn: &mut rusqlite::Connection) -> Res
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn run(args: &Args, conn: &mut rusqlite::Connection) -> Result<(), Error> {
|
pub fn run(args: &Args, conn: &mut rusqlite::Connection) -> Result<(), Error> {
|
||||||
|
db::check_sqlite_version()?;
|
||||||
db::set_integrity_pragmas(conn)?;
|
db::set_integrity_pragmas(conn)?;
|
||||||
set_journal_mode(&conn, args.preset_journal)?;
|
set_journal_mode(&conn, args.preset_journal)?;
|
||||||
upgrade(args, db::EXPECTED_VERSION, conn)?;
|
upgrade(args, db::EXPECTED_VERSION, conn)?;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user