Skip to content

Commit

Permalink
chore: fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
sigoden committed Jan 15, 2024
1 parent e1fabc7 commit 9b348fc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
14 changes: 7 additions & 7 deletions src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ lazy_static! {
pub struct AccessControl {
use_hashed_password: bool,
users: IndexMap<String, (String, AccessPaths)>,
anony: Option<AccessPaths>,
anonymous: Option<AccessPaths>,
}

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)),
}
}
}
Expand Down Expand Up @@ -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}"))?;
Expand All @@ -87,7 +87,7 @@ impl AccessControl {
Ok(Self {
use_hashed_password,
users,
anony,
anonymous,
})
}

Expand Down Expand Up @@ -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)));
}

Expand Down
8 changes: 4 additions & 4 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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());

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -1682,7 +1682,7 @@ fn parse_upload_offset(headers: &HeaderMap<HeaderValue>, size: u64) -> Result<Op
Some(v) => 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));
Expand Down
2 changes: 1 addition & 1 deletion tests/hidden.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 9b348fc

Please sign in to comment.