Fix some lint warning and simplify some code

This commit is contained in:
Cameron Cordes
2021-03-25 13:17:58 -04:00
parent 1539255ae0
commit 31e95dc158
2 changed files with 10 additions and 12 deletions

View File

@@ -234,9 +234,12 @@ async fn favorites(claims: Claims) -> impl Responder {
async fn post_add_favorite(claims: Claims, body: web::Json<AddFavoriteRequest>) -> impl Responder {
if let Ok(user_id) = claims.sub.parse::<i32>() {
let path = body.path.clone();
web::block::<_, _, String>(move || Ok(add_favorite(user_id, path)))
.await
.unwrap();
web::block::<_, _, String>(move || {
add_favorite(user_id, path);
Ok(())
})
.await
.unwrap();
debug!("Adding favorite \"{}\" for userid: {}", user_id, body.path);
HttpResponse::Ok()
} else {
@@ -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
})