From cd4aaaf50139755e5267cb4f731a0b95f083583a Mon Sep 17 00:00:00 2001 From: Nathan Lee Date: Sun, 19 Jul 2026 22:10:07 -0500 Subject: chore: lint --- src/server.rs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/server.rs b/src/server.rs index ced51d1..035f39b 100644 --- a/src/server.rs +++ b/src/server.rs @@ -1,4 +1,4 @@ -use std::fs; +use crate::config::{ServerConfig, read_config}; use axum::body::{Body, HttpBody}; use axum::http::{HeaderMap, Request, Response, StatusCode, header}; use axum::middleware::Next; @@ -16,7 +16,6 @@ use std::path::Path; use std::pin::Pin; use std::sync::OnceLock; use tokio::net::TcpListener; -use crate::config::{read_config, ServerConfig}; static PUBLIC_KEY: OnceLock = OnceLock::new(); static SERVER_CONFIG: OnceLock = OnceLock::new(); @@ -36,7 +35,7 @@ fn parse_header(headers: &HeaderMap, key: &str) -> Result< .ok_or(StatusCode::BAD_REQUEST) } -fn log_challenge(signature: &String, status: ChallengeStatus) { +fn log_challenge(signature: &str, status: ChallengeStatus) { let short_signature = signature.chars().take(10).collect::(); match status { ChallengeStatus::BadTimestamp => println!( @@ -83,13 +82,13 @@ fn perform_download(file: String) -> Result, StatusCode> { Ok(response) } -fn find_short_id_candidates(path: &String, vaults: ReadDir) -> Vec { +fn find_short_id_candidates(path: &str, vaults: ReadDir) -> Vec { let candidates: Vec<_> = vaults .filter_map(|entry| entry.ok()) .map(|entry| entry.path()) .filter(|entry| entry.is_file()) .map(|entry| entry.to_string_lossy().into_owned()) - .filter(|entry| entry[7..].starts_with(path.as_str())) + .filter(|entry| entry[7..].starts_with(path)) .collect(); candidates } @@ -179,13 +178,11 @@ async fn upload(mut body: Body) -> Result { if path.is_file() && let Some(file_name) = path.file_name() + && file_name.to_string_lossy().starts_with(file_hash.as_str()) { - if file_name.to_string_lossy().starts_with(file_hash.as_str()) { - println!("[*] File already exists, doing nothing..."); - std::fs::remove_file(temp_filename) - .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?; - return Ok(StatusCode::NOT_MODIFIED); - } + println!("[*] File already exists, doing nothing..."); + std::fs::remove_file(temp_filename).map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?; + return Ok(StatusCode::NOT_MODIFIED); } } -- cgit v1.2.3