From 93a2495e325a794d24158cf6e8a3a400802a30ba Mon Sep 17 00:00:00 2001 From: Mike Dilger Date: Mon, 18 Nov 2024 08:48:31 +1300 Subject: [PATCH] blossom related clippy fixes --- src/web/blossom/auth.rs | 4 ++-- src/web/blossom/mod.rs | 25 +++++++++++++------------ 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/web/blossom/auth.rs b/src/web/blossom/auth.rs index c5499c6..e481716 100644 --- a/src/web/blossom/auth.rs +++ b/src/web/blossom/auth.rs @@ -32,8 +32,8 @@ pub fn verify_auth(request: &Request) -> Result { match verify_auth_inner(request) { Ok(ad) => Ok(ad), Err(e) => match e.inner { - ChorusError::BlossomAuthFailure(_) => return Err(e), - _ => return Err(ChorusError::BlossomAuthFailure(format!("{e}")).into()), + ChorusError::BlossomAuthFailure(_) => Err(e), + _ => Err(ChorusError::BlossomAuthFailure(format!("{e}")).into()), }, } } diff --git a/src/web/blossom/mod.rs b/src/web/blossom/mod.rs index 9ab5433..4a1372e 100644 --- a/src/web/blossom/mod.rs +++ b/src/web/blossom/mod.rs @@ -29,6 +29,7 @@ pub async fn handle(request: Request) -> Result) -> Result>, Error> { let p = request.uri().path(); + #[allow(clippy::int_plus_one)] if p.starts_with("/") && p.len() >= 1 + 64 && p.chars().skip(1).take(64).all(|c| c.is_ascii_hexdigit()) @@ -118,13 +119,13 @@ pub async fn handle_hash( let metadata = GLOBALS.filestore.get().unwrap().metadata(hash).await?; - match request.method() { - &Method::HEAD => Ok(Response::builder() + match *request.method() { + Method::HEAD => Ok(Response::builder() .header(ACCESS_CONTROL_ALLOW_ORIGIN, "*") .header(CONTENT_LENGTH, format!("{}", metadata.len())) .status(StatusCode::OK) .body(Empty::new().map_err(|e| e.into()).boxed())?), - &Method::GET => { + Method::GET => { let body = GLOBALS.filestore.get().unwrap().retrieve(hash).await?; Ok(Response::builder() .header(ACCESS_CONTROL_ALLOW_ORIGIN, "*") @@ -132,7 +133,7 @@ pub async fn handle_hash( .status(StatusCode::OK) .body(body)?) } - &Method::DELETE => { + Method::DELETE => { let auth_data = verify_auth(&request)?; if auth_data.verb != Some(AuthVerb::Delete) { return Err(ChorusError::BlossomAuthFailure( @@ -170,14 +171,14 @@ pub async fn handle_upload( ); } - match request.method() { - &Method::HEAD => Ok(Response::builder() + match *request.method() { + Method::HEAD => Ok(Response::builder() .header(ACCESS_CONTROL_ALLOW_ORIGIN, "*") .header(CONTENT_LENGTH, "0") .status(StatusCode::NOT_IMPLEMENTED) .body(Empty::new().map_err(|e| e.into()).boxed())?), - &Method::PUT => { - let expected_hash = auth_data.hash.map(|bytes| HashOutput::from_bytes(bytes)); + Method::PUT => { + let expected_hash = auth_data.hash.map(HashOutput::from_bytes); if expected_hash.is_none() { return Err(ChorusError::BlossomAuthFailure( "Put requires an expected hash value x tag in the authorization event" @@ -248,8 +249,8 @@ pub async fn handle_list( return Err(ChorusError::BlossomAuthFailure("List was not authorized".to_string()).into()); } - match request.method() { - &Method::GET => Ok(Response::builder() + match *request.method() { + Method::GET => Ok(Response::builder() .header(ACCESS_CONTROL_ALLOW_ORIGIN, "*") .header(CONTENT_LENGTH, "0") .status(StatusCode::NOT_IMPLEMENTED) @@ -276,8 +277,8 @@ pub async fn handle_mirror( ); } - match request.method() { - &Method::PUT => Ok(Response::builder() + match *request.method() { + Method::PUT => Ok(Response::builder() .header(ACCESS_CONTROL_ALLOW_ORIGIN, "*") .header(CONTENT_LENGTH, "0") .status(StatusCode::NOT_IMPLEMENTED)