From 680b0d001d58a32b0caac3263103dbd9ddb5fe84 Mon Sep 17 00:00:00 2001 From: jikstra Date: Thu, 2 Sep 2021 15:50:35 +0200 Subject: cargo fmt & cargo clippy --- src/auth.rs | 4 ++-- src/listing.rs | 2 +- src/renderer.rs | 17 +++++------------ tests/raw.rs | 8 +++----- 4 files changed, 11 insertions(+), 20 deletions(-) diff --git a/src/auth.rs b/src/auth.rs index efdeefb..82b407c 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -90,10 +90,10 @@ fn handle_auth(req: &HttpRequest) -> Result<(), ContextualError> { Ok(cred) => match match_auth(&cred, required_auth) { true => { req.extensions_mut().insert(CurrentUser { - name: cred.username + name: cred.username, }); Ok(()) - }, + } false => Err(ContextualError::InvalidHttpCredentials), }, Err(_) => Err(ContextualError::RequireHttpCredentials), diff --git a/src/listing.rs b/src/listing.rs index c1c9597..20768f1 100644 --- a/src/listing.rs +++ b/src/listing.rs @@ -379,7 +379,7 @@ pub fn directory_listing( breadcrumbs, &encoded_dir, conf, - current_user + current_user, ) .into_string(), ), diff --git a/src/renderer.rs b/src/renderer.rs index b18ac07..45cb145 100644 --- a/src/renderer.rs +++ b/src/renderer.rs @@ -21,18 +21,16 @@ pub fn page( current_user: Option<&CurrentUser>, ) -> Markup { // If query_params.raw is true, we want render a minimal directory listing - if query_params.raw.is_some() && query_params.raw.unwrap() == true { + if query_params.raw.is_some() && query_params.raw.unwrap() { return raw(entries, is_root); } - + let upload_route = match conf.random_route { Some(ref random_route) => format!("/{}/upload", random_route), None => "/upload".to_string(), }; let (sort_method, sort_order) = (query_params.sort, query_params.order); - - - + let upload_action = build_upload_action(&upload_route, encoded_dir, sort_method, sort_order); let title_path = breadcrumbs @@ -40,8 +38,6 @@ pub fn page( .map(|el| el.name.clone()) .collect::>() .join("/"); - - html! { (DOCTYPE) @@ -159,10 +155,7 @@ pub fn page( } /// Renders the file listing #[allow(clippy::too_many_arguments)] -pub fn raw( - entries: Vec, - is_root: bool -) -> Markup { +pub fn raw(entries: Vec, is_root: bool) -> Markup { html! { (DOCTYPE) html { @@ -594,7 +587,7 @@ pub fn render_error( p.footer { (version_footer()) } - + } } } diff --git a/tests/raw.rs b/tests/raw.rs index 57d1436..6e0c2a0 100644 --- a/tests/raw.rs +++ b/tests/raw.rs @@ -73,12 +73,12 @@ fn raw_mode_links_to_directories_end_with_raw_true(server: TestServer) -> Result } else if class == "file" { assert!(true); } else { - println!( + println!( "This node is a link and neither of class directory, root or file: {:?}", node ); assert!(false); - } + } } } } @@ -90,17 +90,15 @@ fn raw_mode_links_to_directories_end_with_raw_true(server: TestServer) -> Result format!("{}very/deeply/nested/?raw=true", server.url()), ]; - let client = Client::new(); // Ensure the links to the archives are not present for url in urls.iter() { let body = client.get(url).send()?.error_for_status()?; - + let body = client.get(url).send()?.error_for_status()?; let parsed = Document::from_read(body)?; verify_a_tags(parsed); } - Ok(()) } -- cgit v1.2.3