Fix cargo clippy issues
This commit is contained in:
		
							
								
								
									
										12
									
								
								src/main.rs
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								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<Args>, 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<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() { | ||||
|         return Err(ErrorBadRequest("No file to extract!")); | ||||
|     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user