diff --git a/Jenkinsfile b/Jenkinsfile index 9bbecdb..14395c2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,7 +1,7 @@ pipeline { agent { docker { - image 'rust:1.48' + image 'rust:1.51' args '-v "$PWD":/usr/src/image-api' } } diff --git a/src/database/mod.rs b/src/database/mod.rs index ff4c679..432b17b 100644 --- a/src/database/mod.rs +++ b/src/database/mod.rs @@ -144,9 +144,7 @@ pub mod testhelpers { .user_map .borrow() .iter() - .filter(|u| u.username == user && u.password == pass) - .collect::>() - .first() + .find(|&u| u.username == user && u.password == pass) { Some(u) => { let copy = (*u).clone(); @@ -160,9 +158,7 @@ pub mod testhelpers { self.user_map .borrow() .iter() - .filter(|u| u.username == user) - .collect::>() - .first() + .find(|&u| u.username == user) .is_some() } } diff --git a/src/main.rs b/src/main.rs index fc2b790..1b160d8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -234,10 +234,13 @@ async fn favorites(claims: Claims) -> impl Responder { async fn post_add_favorite(claims: Claims, body: web::Json) -> impl Responder { if let Ok(user_id) = claims.sub.parse::() { let path = body.path.clone(); - web::block::<_, _, String>(move || Ok(add_favorite(user_id, path))) - .await - .unwrap(); - debug!("Adding favorite \"{}\" for userid: {}", user_id, body.path); + web::block::<_, _, String>(move || { + add_favorite(user_id, path); + Ok(()) + }) + .await + .unwrap(); + debug!("Adding favorite \"{}\" for userid: {}", body.path, user_id); HttpResponse::Ok() } else { error!("Unable to parse sub as i32: {}", claims.sub); @@ -330,9 +333,8 @@ fn main() -> std::io::Result<()> { DebouncedEvent::Rename(orig, _) | DebouncedEvent::Write(orig) => { let image_base_path = PathBuf::from(env::var("BASE_PATH").unwrap()); let image_relative = orig.strip_prefix(&image_base_path).unwrap(); - if let Ok(old_thumbnail) = env::var("THUMBNAILS") - .map(|base| PathBuf::from(base)) - .map(|mut base| { + if let Ok(old_thumbnail) = + env::var("THUMBNAILS").map(PathBuf::from).map(|mut base| { base.push(image_relative); base })