chore: fix typos
This commit is contained in:
parent
e1fabc7349
commit
9b348fc945
3 changed files with 12 additions and 12 deletions
14
src/auth.rs
14
src/auth.rs
|
@ -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)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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)));
|
||||
}
|
||||
|
||||
|
|
|
@ -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<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));
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue