diff --git a/src/config.rs b/src/config.rs index 1e3c57c..c8235f6 100644 --- a/src/config.rs +++ b/src/config.rs @@ -100,7 +100,8 @@ where index_album_art_pattern, index_sleep_duration_seconds, prefix_url, - )).get_result(connection.deref())?; + )) + .get_result(connection.deref())?; config.album_art_pattern = Some(art_pattern); config.reindex_every_n_seconds = Some(sleep_duration); config.prefix_url = if url != "" { Some(url) } else { None }; @@ -124,7 +125,8 @@ where name, password: "".to_owned(), admin: admin != 0, - }).collect::<_>(), + }) + .collect::<_>(), ); let ydns = ddns_config @@ -194,7 +196,8 @@ where .iter() .find(|old_name| *old_name == &u.name) .is_none() - }).collect::<_>(); + }) + .collect::<_>(); for config_user in &insert_users { let new_user = User::new(&config_user.name, &config_user.password); diesel::insert_into(users::table) @@ -242,7 +245,8 @@ where host.eq(ydns.host.clone()), username.eq(ydns.username.clone()), password.eq(ydns.password.clone()), - )).execute(connection.deref())?; + )) + .execute(connection.deref())?; } if let Some(ref prefix_url) = new_config.prefix_url { diff --git a/src/index.rs b/src/index.rs index f6da66e..aadc115 100644 --- a/src/index.rs +++ b/src/index.rs @@ -318,7 +318,8 @@ where .filter(|ref song_path| { let path = Path::new(&song_path); !path.exists() || vfs.real_to_virtual(path).is_err() - }).collect::>(); + }) + .collect::>(); { let connection = db.get_connection(); @@ -343,7 +344,8 @@ where .filter(|ref directory_path| { let path = Path::new(&directory_path); !path.exists() || vfs.real_to_virtual(path).is_err() - }).collect::>(); + }) + .collect::>(); { let connection = db.get_connection(); @@ -623,7 +625,8 @@ where .or(album.like(&like_test)) .or(artist.like(&like_test)) .or(album_artist.like(&like_test)), - ).filter(parent.not_like(&like_test)) + ) + .filter(parent.not_like(&like_test)) .load(connection.deref())?; let virtual_songs = real_songs diff --git a/src/main.rs b/src/main.rs index 4fe8b04..15f83b0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -75,7 +75,6 @@ use std::sync::mpsc::channel; use std::sync::{Arc, Mutex}; mod api; -mod rocket_api; mod config; mod db; mod ddns; @@ -84,6 +83,7 @@ mod index; mod lastfm; mod metadata; mod playlist; +mod rocket_api; mod serve; mod thumbnails; mod ui; @@ -269,10 +269,10 @@ fn run() -> Result<()> { }; rocket::ignite() - .manage(db::DB::new(&db_path)?) - .mount(&static_url, StaticFiles::from(web_dir_path)) - .mount(&api_url, rocket_api::get_routes()) - .launch(); + .manage(db::DB::new(&db_path)?) + .mount(&static_url, StaticFiles::from(web_dir_path)) + .mount(&api_url, rocket_api::get_routes()) + .launch(); // Start DDNS updates let db_ref = db.clone(); diff --git a/src/rocket_api.rs b/src/rocket_api.rs index ba156a5..7e74ebd 100644 --- a/src/rocket_api.rs +++ b/src/rocket_api.rs @@ -1,6 +1,6 @@ -use rocket::{Outcome, State}; use rocket::http::{Cookies, Status}; -use rocket::request::{self, Request, FromRequest}; +use rocket::request::{self, FromRequest, Request}; +use rocket::{Outcome, State}; use rocket_contrib::json::Json; use config::{self, Config}; @@ -12,11 +12,7 @@ const CURRENT_MAJOR_VERSION: i32 = 2; const CURRENT_MINOR_VERSION: i32 = 2; pub fn get_routes() -> Vec { - routes![ - version, - initial_setup, - get_settings, - ] + routes![version, initial_setup, get_settings,] } struct Auth { @@ -29,10 +25,12 @@ impl<'a, 'r> FromRequest<'a, 'r> for Auth { fn from_request(request: &'a Request<'r>) -> request::Outcome { let mut cookies = request.guard::().unwrap(); match cookies.get_private("username") { - Some(u) => Outcome::Success(Auth { username: u.to_string() }), - _ => Outcome::Failure((Status::Forbidden, ())) + Some(u) => Outcome::Success(Auth { + username: u.to_string(), + }), + _ => Outcome::Failure((Status::Forbidden, ())), } - } + } } struct AdminRights {} @@ -45,7 +43,7 @@ impl<'a, 'r> FromRequest<'a, 'r> for AdminRights { match user::count::(&db) { Err(_) => return Outcome::Failure((Status::InternalServerError, ())), Ok(0) => return Outcome::Success(AdminRights {}), - _ => () + _ => (), }; let auth = request.guard::()?; @@ -54,7 +52,7 @@ impl<'a, 'r> FromRequest<'a, 'r> for AdminRights { Ok(true) => Outcome::Success(AdminRights {}), Ok(false) => Outcome::Failure((Status::Forbidden, ())), } - } + } } #[derive(Serialize)] diff --git a/src/user.rs b/src/user.rs index 96f19ee..fdeaec7 100644 --- a/src/user.rs +++ b/src/user.rs @@ -58,7 +58,8 @@ fn verify_password( password_salt, attempted_password.as_bytes(), password_hash, - ).is_ok() + ) + .is_ok() } pub fn auth(db: &T, username: &str, password: &str) -> Result @@ -111,7 +112,8 @@ where .set(( lastfm_username.eq(lastfm_login), lastfm_session_key.eq(session_key), - )).execute(connection.deref())?; + )) + .execute(connection.deref())?; Ok(()) }