From 9b348fc9450f254eaff2136e4da9f732386a45de Mon Sep 17 00:00:00 2001 From: sigoden Date: Mon, 15 Jan 2024 12:53:59 +0000 Subject: [PATCH] chore: fix typos --- src/auth.rs | 14 +++++++------- src/server.rs | 8 ++++---- tests/hidden.rs | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/auth.rs b/src/auth.rs index 6127cb7..937dc3e 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -29,15 +29,15 @@ lazy_static! { pub struct AccessControl { use_hashed_password: bool, users: IndexMap, - anony: Option, + anonymous: Option, } impl Default for AccessControl { fn default() -> Self { AccessControl { use_hashed_password: false, - anony: Some(AccessPaths::new(AccessPerm::ReadWrite)), users: IndexMap::new(), + anonymous: Some(AccessPaths::new(AccessPerm::ReadWrite)), } } } @@ -66,15 +66,15 @@ impl AccessControl { account_paths_pairs.push((user, pass, paths)); } } - let mut anony = None; + let mut anonymous = None; if let Some(paths) = annoy_paths { let mut access_paths = AccessPaths::default(); access_paths.merge(paths); - anony = Some(access_paths); + anonymous = Some(access_paths); } let mut users = IndexMap::new(); for (user, pass, paths) in account_paths_pairs.into_iter() { - let mut access_paths = anony.clone().unwrap_or_default(); + let mut access_paths = anonymous.clone().unwrap_or_default(); access_paths .merge(paths) .ok_or_else(|| anyhow!("Invalid auth `{user}:{pass}@{paths}"))?; @@ -87,7 +87,7 @@ impl AccessControl { Ok(Self { use_hashed_password, users, - anony, + anonymous, }) } @@ -120,7 +120,7 @@ impl AccessControl { return (None, Some(AccessPaths::new(AccessPerm::ReadOnly))); } - if let Some(paths) = self.anony.as_ref() { + if let Some(paths) = self.anonymous.as_ref() { return (None, paths.find(path, !is_readonly_method(method))); } diff --git a/src/server.rs b/src/server.rs index ed5b3fe..72d8cef 100644 --- a/src/server.rs +++ b/src/server.rs @@ -623,7 +623,7 @@ impl Server { ) -> Result<()> { let (mut writer, reader) = tokio::io::duplex(BUF_SIZE); let filename = try_get_file_name(path)?; - set_content_diposition(res, false, &format!("{}.zip", filename))?; + set_content_disposition(res, false, &format!("{}.zip", filename))?; res.headers_mut() .insert("content-type", HeaderValue::from_static("application/zip")); if head_only { @@ -811,7 +811,7 @@ impl Server { ); let filename = try_get_file_name(path)?; - set_content_diposition(res, true, filename)?; + set_content_disposition(res, true, filename)?; res.headers_mut().typed_insert(AcceptRanges::bytes()); @@ -1599,7 +1599,7 @@ fn status_bad_request(res: &mut Response, body: &str) { } } -fn set_content_diposition(res: &mut Response, inline: bool, filename: &str) -> Result<()> { +fn set_content_disposition(res: &mut Response, inline: bool, filename: &str) -> Result<()> { let kind = if inline { "inline" } else { "attachment" }; let filename: String = filename .chars() @@ -1682,7 +1682,7 @@ fn parse_upload_offset(headers: &HeaderMap, size: u64) -> Result v, None => return Ok(None), }; - let err = || anyhow!("Invalid X-Updage-Range header"); + let err = || anyhow!("Invalid X-Update-Range header"); let value = value.to_str().map_err(|_| err())?; if value == "append" { return Ok(Some(size)); diff --git a/tests/hidden.rs b/tests/hidden.rs index 5156f51..3a77171 100644 --- a/tests/hidden.rs +++ b/tests/hidden.rs @@ -59,7 +59,7 @@ fn hidden_search_dir(#[case] server: TestServer, #[case] exist: bool) -> Result< #[rstest] #[case(server(&["--hidden", "hidden/"]), "dir4/", 1)] #[case(server(&["--hidden", "hidden"]), "dir4/", 0)] -fn hidden_dir_noly( +fn hidden_dir_only( #[case] server: TestServer, #[case] dir: &str, #[case] count: usize,