Fix cargo clippy issues
This commit is contained in:
parent
d85cce8264
commit
8d225656aa
12
src/main.rs
12
src/main.rs
@ -90,11 +90,11 @@ fn get_remote_ip(req: &HttpRequest, args: &Args) -> String {
|
|||||||
.to_str()
|
.to_str()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.to_string()
|
.to_string()
|
||||||
.split(",")
|
.split(',')
|
||||||
.map(|f| f.to_string())
|
.map(|f| f.to_string())
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
if header.len() > 0 {
|
if !header.is_empty() {
|
||||||
ip = header[0].to_string();
|
ip = header[0].to_string();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -157,16 +157,18 @@ async fn replace_files(args: web::Data<Args>, req: HttpRequest, mut payload: Mul
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove base URI before extraction
|
||||||
let mut inner_path_str = &inner_path_str[base_uri.len()..];
|
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..];
|
inner_path_str = &inner_path_str[1..];
|
||||||
}
|
}
|
||||||
let inner_path = Path::new(inner_path_str);
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Read file to buffer
|
||||||
let dest_file = args.storage_path().join(inner_path);
|
let dest_file = args.storage_path().join(inner_path);
|
||||||
let mut buf = Vec::with_capacity(file.size() as usize);
|
let mut buf = Vec::with_capacity(file.size() as usize);
|
||||||
file.read_to_end(&mut buf)?;
|
file.read_to_end(&mut buf)?;
|
||||||
@ -178,7 +180,7 @@ async fn replace_files(args: web::Data<Args>, 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() {
|
if new_files.is_empty() {
|
||||||
return Err(ErrorBadRequest("No file to extract!"));
|
return Err(ErrorBadRequest("No file to extract!"));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user