mirror of
https://github.com/scottlamb/moonfire-nvr.git
synced 2025-01-14 08:15:01 -05:00
improve error messages on unparseable text protos
Takes advantage of stepancheg/rust-protobuf#428
This commit is contained in:
parent
79ac89dc7c
commit
01d20960ef
6
Cargo.lock
generated
6
Cargo.lock
generated
@ -1473,12 +1473,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "protobuf"
|
name = "protobuf"
|
||||||
version = "3.0.0-pre"
|
version = "3.0.0-pre"
|
||||||
source = "git+https://github.com/stepancheg/rust-protobuf#4c97ba2a1624626d2ac8472ec9139613744f1de9"
|
source = "git+https://github.com/stepancheg/rust-protobuf#c28865f0ada87733b80806eecbdcbd4906d13ee3"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "protobuf-codegen"
|
name = "protobuf-codegen"
|
||||||
version = "3.0.0-pre"
|
version = "3.0.0-pre"
|
||||||
source = "git+https://github.com/stepancheg/rust-protobuf#4c97ba2a1624626d2ac8472ec9139613744f1de9"
|
source = "git+https://github.com/stepancheg/rust-protobuf#c28865f0ada87733b80806eecbdcbd4906d13ee3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"protobuf 3.0.0-pre (git+https://github.com/stepancheg/rust-protobuf)",
|
"protobuf 3.0.0-pre (git+https://github.com/stepancheg/rust-protobuf)",
|
||||||
]
|
]
|
||||||
@ -1486,7 +1486,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "protobuf-codegen-pure"
|
name = "protobuf-codegen-pure"
|
||||||
version = "3.0.0-pre"
|
version = "3.0.0-pre"
|
||||||
source = "git+https://github.com/stepancheg/rust-protobuf#4c97ba2a1624626d2ac8472ec9139613744f1de9"
|
source = "git+https://github.com/stepancheg/rust-protobuf#c28865f0ada87733b80806eecbdcbd4906d13ee3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"protobuf 3.0.0-pre (git+https://github.com/stepancheg/rust-protobuf)",
|
"protobuf 3.0.0-pre (git+https://github.com/stepancheg/rust-protobuf)",
|
||||||
"protobuf-codegen 3.0.0-pre (git+https://github.com/stepancheg/rust-protobuf)",
|
"protobuf-codegen 3.0.0-pre (git+https://github.com/stepancheg/rust-protobuf)",
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
use base::clock::{self, Clocks};
|
use base::clock::{self, Clocks};
|
||||||
use db::auth::SessionFlags;
|
use db::auth::SessionFlags;
|
||||||
use failure::{Error, bail, format_err};
|
use failure::{Error, ResultExt, bail, format_err};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::os::unix::fs::OpenOptionsExt as _;
|
use std::os::unix::fs::OpenOptionsExt as _;
|
||||||
use std::io::Write as _;
|
use std::io::Write as _;
|
||||||
@ -89,7 +89,7 @@ pub fn run() -> Result<(), Error> {
|
|||||||
let permissions = match args.flag_permissions {
|
let permissions = match args.flag_permissions {
|
||||||
None => u.permissions.clone(),
|
None => u.permissions.clone(),
|
||||||
Some(s) => protobuf::text_format::parse_from_str(&s)
|
Some(s) => protobuf::text_format::parse_from_str(&s)
|
||||||
.map_err(|_| format_err!("unable to parse --permissions"))?
|
.context("unable to parse --permissions")?
|
||||||
};
|
};
|
||||||
let creation = db::auth::Request {
|
let creation = db::auth::Request {
|
||||||
when_sec: Some(db.clocks().realtime().sec),
|
when_sec: Some(db.clocks().realtime().sec),
|
||||||
|
@ -33,7 +33,7 @@ use crate::stream;
|
|||||||
use crate::streamer;
|
use crate::streamer;
|
||||||
use crate::web;
|
use crate::web;
|
||||||
use db::{dir, writer};
|
use db::{dir, writer};
|
||||||
use failure::{Error, bail, format_err};
|
use failure::{Error, ResultExt, bail};
|
||||||
use fnv::FnvHashMap;
|
use fnv::FnvHashMap;
|
||||||
use futures::{Future, Stream};
|
use futures::{Future, Stream};
|
||||||
use log::{error, info, warn};
|
use log::{error, info, warn};
|
||||||
@ -195,7 +195,7 @@ pub fn run() -> Result<(), Error> {
|
|||||||
let allow_unauthenticated_permissions = args.flag_allow_unauthenticated_permissions
|
let allow_unauthenticated_permissions = args.flag_allow_unauthenticated_permissions
|
||||||
.map(|s| protobuf::text_format::parse_from_str(&s))
|
.map(|s| protobuf::text_format::parse_from_str(&s))
|
||||||
.transpose()
|
.transpose()
|
||||||
.map_err(|_| format_err!("Unable to parse --allow-unauthenticated-permissions"))?;
|
.context("Unable to parse --allow-unauthenticated-permissions")?;
|
||||||
let s = web::Service::new(web::Config {
|
let s = web::Service::new(web::Config {
|
||||||
db: db.clone(),
|
db: db.clone(),
|
||||||
ui_dir: Some(&args.flag_ui_dir),
|
ui_dir: Some(&args.flag_ui_dir),
|
||||||
|
Loading…
Reference in New Issue
Block a user