From 8d225656aa12df55d977c10d5e8fff870249926f Mon Sep 17 00:00:00 2001 From: Pierre Hubert Date: Sun, 27 Mar 2022 14:31:23 +0200 Subject: [PATCH] Fix cargo clippy issues --- src/main.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 2957ae1..6dcac7f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -90,11 +90,11 @@ fn get_remote_ip(req: &HttpRequest, args: &Args) -> String { .to_str() .unwrap() .to_string() - .split(",") + .split(',') .map(|f| f.to_string()) .collect(); - if header.len() > 0 { + if !header.is_empty() { ip = header[0].to_string(); } } @@ -157,16 +157,18 @@ async fn replace_files(args: web::Data, req: HttpRequest, mut payload: Mul continue; } + // Remove base URI before extraction let mut inner_path_str = &inner_path_str[base_uri.len()..]; - if inner_path_str.starts_with("/") { + if inner_path_str.starts_with('/') { inner_path_str = &inner_path_str[1..]; } let inner_path = Path::new(inner_path_str); - if inner_path.is_dir() || inner_path_str.ends_with("/") || inner_path_str.is_empty() { + if inner_path.is_dir() || inner_path_str.ends_with('/') || inner_path_str.is_empty() { continue; } + // Read file to buffer let dest_file = args.storage_path().join(inner_path); let mut buf = Vec::with_capacity(file.size() as usize); file.read_to_end(&mut buf)?; @@ -178,7 +180,7 @@ async fn replace_files(args: web::Data, req: HttpRequest, mut payload: Mul } } - // Check if at least a file was sent + // Check if at least one file was sent if new_files.is_empty() { return Err(ErrorBadRequest("No file to extract!")); }