Skip to content

Commit

Permalink
Remove unnecessary borrow expressions and immediate dereferences
Browse files Browse the repository at this point in the history
  • Loading branch information
marshallku committed Sep 7, 2024
1 parent db1fc37 commit ad8ef1c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/utils/img.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ pub async fn save_resized_image(
target_path: &PathBuf,
) -> Response {
if width.is_none() {
return response_file(&target_path).await;
return response_file(target_path).await;
}

if image.width() <= width.unwrap() {
copy(&original_path, &target_path).ok();
return response_file(&target_path).await;
copy(original_path, target_path).ok();
return response_file(target_path).await;
}

let resize_height = width.unwrap() * image.height() / image.width();
let resized_image = image.thumbnail(width.unwrap(), resize_height);

match resized_image.save(target_path.clone()) {
Ok(_) => response_file(&target_path).await,
Ok(_) => response_file(target_path).await,
Err(_) => response_error(StatusCode::INTERNAL_SERVER_ERROR),
}
}

0 comments on commit ad8ef1c

Please sign in to comment.