mirror of
https://github.com/scottlamb/moonfire-nvr.git
synced 2025-11-28 21:18:11 -05:00
address some no-op clippy warnings
This commit is contained in:
@@ -279,7 +279,7 @@ fn lower_retention(
|
||||
db: &Arc<db::Database>,
|
||||
zero_limits: BTreeMap<i32, Vec<writer::NewLimit>>,
|
||||
) -> Result<(), Error> {
|
||||
let dirs_to_open: Vec<_> = zero_limits.keys().map(|id| *id).collect();
|
||||
let dirs_to_open: Vec<_> = zero_limits.keys().copied().collect();
|
||||
db.lock().open_sample_file_dirs(&dirs_to_open[..])?;
|
||||
for (&dir_id, l) in &zero_limits {
|
||||
writer::lower_retention(db.clone(), dir_id, &l)?;
|
||||
@@ -358,7 +358,7 @@ fn edit_camera_dialog(db: &Arc<db::Database>, siv: &mut Cursive, item: &Option<i
|
||||
.child(
|
||||
"sample file dir",
|
||||
views::SelectView::<Option<i32>>::new()
|
||||
.with_all(dirs.iter().map(|d| d.clone()))
|
||||
.with_all(dirs.iter().cloned())
|
||||
.popup()
|
||||
.with_name(format!("{}_sample_file_dir", type_.as_str())),
|
||||
)
|
||||
|
||||
@@ -408,10 +408,7 @@ fn edit_dir_dialog(db: &Arc<db::Database>, siv: &mut Cursive, dir_id: i32) {
|
||||
.child(views::DummyView {}.fixed_width(20))
|
||||
.child(views::TextView::new(encode_size(model.borrow().fs_capacity)).fixed_width(25)),
|
||||
);
|
||||
let mut change_button = views::Button::new("Change", {
|
||||
let model = model.clone();
|
||||
move |siv| press_change(&model, siv)
|
||||
});
|
||||
let mut change_button = views::Button::new("Change", move |siv| press_change(&model, siv));
|
||||
change_button.set_enabled(!over);
|
||||
let mut buttons = views::LinearLayout::horizontal().child(views::DummyView.full_width());
|
||||
buttons.add_child(change_button.with_name("change"));
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
use base::clock;
|
||||
use cursive::views;
|
||||
use cursive::Cursive;
|
||||
use db;
|
||||
use failure::Error;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
@@ -43,10 +42,7 @@ pub fn run(args: &Args) -> Result<i32, Error> {
|
||||
siv.add_layer(
|
||||
views::Dialog::around(
|
||||
views::SelectView::<fn(&Arc<db::Database>, &mut Cursive)>::new()
|
||||
.on_submit({
|
||||
let db = db.clone();
|
||||
move |siv, item| item(&db, siv)
|
||||
})
|
||||
.on_submit(move |siv, item| item(&db, siv))
|
||||
.item("Cameras and streams".to_string(), cameras::top_dialog)
|
||||
.item("Directories and retention".to_string(), dirs::top_dialog)
|
||||
.item("Users".to_string(), users::top_dialog),
|
||||
|
||||
@@ -126,12 +126,12 @@ fn edit_user_dialog(db: &Arc<db::Database>, siv: &mut Cursive, item: Option<i32>
|
||||
{
|
||||
let l = db.lock();
|
||||
let u = item.map(|id| l.users_by_id().get(&id).unwrap());
|
||||
username = u.map(|u| u.username.clone()).unwrap_or(String::new());
|
||||
id_str = item.map(|id| id.to_string()).unwrap_or("<new>".to_string());
|
||||
username = u.map(|u| u.username.clone()).unwrap_or_default();
|
||||
id_str = item
|
||||
.map(|id| id.to_string())
|
||||
.unwrap_or_else(|| "<new>".to_string());
|
||||
has_password = u.map(|u| u.has_password()).unwrap_or(false);
|
||||
permissions = u
|
||||
.map(|u| u.permissions.clone())
|
||||
.unwrap_or(db::Permissions::default());
|
||||
permissions = u.map(|u| u.permissions.clone()).unwrap_or_default();
|
||||
}
|
||||
let top_list = views::ListView::new()
|
||||
.child("id", views::TextView::new(id_str))
|
||||
|
||||
@@ -56,7 +56,7 @@ pub struct Args {
|
||||
pub fn run(args: &Args) -> Result<i32, Error> {
|
||||
let clocks = clock::RealClocks {};
|
||||
let (_db_dir, conn) = super::open_conn(&args.db_dir, super::OpenMode::ReadWrite)?;
|
||||
let db = std::sync::Arc::new(db::Database::new(clocks.clone(), conn, true).unwrap());
|
||||
let db = std::sync::Arc::new(db::Database::new(clocks, conn, true).unwrap());
|
||||
let mut l = db.lock();
|
||||
let u = l
|
||||
.get_user(&args.username)
|
||||
@@ -72,7 +72,6 @@ pub fn run(args: &Args) -> Result<i32, Error> {
|
||||
flags |= *f as i32;
|
||||
}
|
||||
let uid = u.id;
|
||||
drop(u);
|
||||
let (sid, _) = l.make_session(
|
||||
creation,
|
||||
uid,
|
||||
|
||||
@@ -6,7 +6,6 @@ use db::dir;
|
||||
use failure::{Error, Fail};
|
||||
use log::info;
|
||||
use nix::fcntl::FlockArg;
|
||||
use rusqlite;
|
||||
use std::path::Path;
|
||||
|
||||
pub mod check;
|
||||
|
||||
@@ -17,7 +17,6 @@ use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::Arc;
|
||||
use std::thread;
|
||||
use structopt::StructOpt;
|
||||
use tokio;
|
||||
use tokio::signal::unix::{signal, SignalKind};
|
||||
|
||||
#[derive(StructOpt)]
|
||||
@@ -76,20 +75,20 @@ pub struct Args {
|
||||
|
||||
// These are used in a hack to get the name of the current time zone (e.g. America/Los_Angeles).
|
||||
// They seem to be correct for Linux and macOS at least.
|
||||
const LOCALTIME_PATH: &'static str = "/etc/localtime";
|
||||
const TIMEZONE_PATH: &'static str = "/etc/timezone";
|
||||
const ZONEINFO_PATHS: [&'static str; 2] = [
|
||||
const LOCALTIME_PATH: &str = "/etc/localtime";
|
||||
const TIMEZONE_PATH: &str = "/etc/timezone";
|
||||
const ZONEINFO_PATHS: [&str; 2] = [
|
||||
"/usr/share/zoneinfo/", // Linux, macOS < High Sierra
|
||||
"/var/db/timezone/zoneinfo/", // macOS High Sierra
|
||||
];
|
||||
|
||||
fn trim_zoneinfo(p: &str) -> &str {
|
||||
fn trim_zoneinfo(path: &str) -> &str {
|
||||
for zp in &ZONEINFO_PATHS {
|
||||
if p.starts_with(zp) {
|
||||
return &p[zp.len()..];
|
||||
if let Some(p) = path.strip_prefix(zp) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
return p;
|
||||
path
|
||||
}
|
||||
|
||||
/// Attempt to resolve the timezone of the server.
|
||||
@@ -145,7 +144,7 @@ fn resolve_zone() -> Result<String, Error> {
|
||||
|
||||
// If `TIMEZONE_PATH` is a file, use its contents as the zone name.
|
||||
match ::std::fs::read_to_string(TIMEZONE_PATH) {
|
||||
Ok(z) => return Ok(z),
|
||||
Ok(z) => Ok(z),
|
||||
Err(e) => {
|
||||
bail!(
|
||||
"Unable to resolve timezone from TZ env, {}, or {}. Last error: {}",
|
||||
@@ -174,7 +173,7 @@ pub async fn run(args: &Args) -> Result<i32, Error> {
|
||||
super::OpenMode::ReadWrite
|
||||
},
|
||||
)?;
|
||||
let db = Arc::new(db::Database::new(clocks.clone(), conn, !args.read_only).unwrap());
|
||||
let db = Arc::new(db::Database::new(clocks, conn, !args.read_only).unwrap());
|
||||
info!("Database is loaded.");
|
||||
|
||||
let object_detector = match args.object_detection {
|
||||
@@ -260,7 +259,7 @@ pub async fn run(args: &Args) -> Result<i32, Error> {
|
||||
let rotate_offset_sec = streamer::ROTATE_INTERVAL_SEC * i as i64 / streams as i64;
|
||||
let syncer = syncers.get(&sample_file_dir_id).unwrap();
|
||||
let object_detector = match stream.type_ {
|
||||
db::StreamType::SUB => object_detector.clone(),
|
||||
db::StreamType::Sub => object_detector.clone(),
|
||||
_ => None,
|
||||
};
|
||||
let mut streamer = streamer::Streamer::new(
|
||||
|
||||
@@ -45,10 +45,7 @@ pub fn run(args: &Args) -> Result<i32, Error> {
|
||||
|
||||
db::upgrade::run(
|
||||
&db::upgrade::Args {
|
||||
sample_file_dir: args
|
||||
.sample_file_dir
|
||||
.as_ref()
|
||||
.map(std::path::PathBuf::as_path),
|
||||
sample_file_dir: args.sample_file_dir.as_deref(),
|
||||
preset_journal: &args.preset_journal,
|
||||
no_vacuum: args.no_vacuum,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user