chore: fix typo
This commit is contained in:
parent
a489c5647a
commit
cc0014c183
10 changed files with 25 additions and 25 deletions
|
@ -75,7 +75,7 @@ class Uploader {
|
|||
}
|
||||
|
||||
ajax() {
|
||||
Uploader.runings += 1;
|
||||
Uploader.runnings += 1;
|
||||
const url = getUrl(this.name);
|
||||
this.lastUptime = Date.now();
|
||||
const ajax = new XMLHttpRequest();
|
||||
|
@ -110,20 +110,20 @@ class Uploader {
|
|||
|
||||
complete() {
|
||||
this.$uploadStatus.innerHTML = `✓`;
|
||||
Uploader.runings -= 1;
|
||||
Uploader.runnings -= 1;
|
||||
Uploader.runQueue();
|
||||
}
|
||||
|
||||
fail() {
|
||||
this.$uploadStatus.innerHTML = `✗`;
|
||||
Uploader.runings -= 1;
|
||||
Uploader.runnings -= 1;
|
||||
Uploader.runQueue();
|
||||
}
|
||||
}
|
||||
|
||||
Uploader.globalIdx = 0;
|
||||
|
||||
Uploader.runings = 0;
|
||||
Uploader.runnings = 0;
|
||||
|
||||
/**
|
||||
* @type Uploader[]
|
||||
|
@ -132,7 +132,7 @@ Uploader.queues = [];
|
|||
|
||||
|
||||
Uploader.runQueue = () => {
|
||||
if (Uploader.runings > 2) return;
|
||||
if (Uploader.runnings > 2) return;
|
||||
let uploader = Uploader.queues.shift();
|
||||
if (!uploader) return;
|
||||
uploader.ajax();
|
||||
|
|
|
@ -357,12 +357,12 @@ fn strip_prefix<'a>(search: &'a [u8], prefix: &[u8]) -> Option<&'a [u8]> {
|
|||
|
||||
fn to_headermap(header: &[u8]) -> Result<HashMap<&[u8], &[u8]>, ()> {
|
||||
let mut sep = Vec::new();
|
||||
let mut asign = Vec::new();
|
||||
let mut assign = Vec::new();
|
||||
let mut i: usize = 0;
|
||||
let mut esc = false;
|
||||
for c in header {
|
||||
match (c, esc) {
|
||||
(b'=', false) => asign.push(i),
|
||||
(b'=', false) => assign.push(i),
|
||||
(b',', false) => sep.push(i),
|
||||
(b'"', false) => esc = true,
|
||||
(b'"', true) => esc = false,
|
||||
|
@ -374,7 +374,7 @@ fn to_headermap(header: &[u8]) -> Result<HashMap<&[u8], &[u8]>, ()> {
|
|||
|
||||
i = 0;
|
||||
let mut ret = HashMap::new();
|
||||
for (&k, &a) in sep.iter().zip(asign.iter()) {
|
||||
for (&k, &a) in sep.iter().zip(assign.iter()) {
|
||||
while header[i] == b' ' {
|
||||
i += 1;
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ fn serve(
|
|||
let inner = inner.clone();
|
||||
let incoming = create_addr_incoming(SocketAddr::new(*ip, port))
|
||||
.map_err(|e| format!("Failed to bind `{}:{}`, {}", ip, port, e))?;
|
||||
let serv_func = move |remote_addr: SocketAddr| {
|
||||
let serve_func = move |remote_addr: SocketAddr| {
|
||||
let inner = inner.clone();
|
||||
async move {
|
||||
Ok::<_, hyper::Error>(service_fn(move |req: Request| {
|
||||
|
@ -99,7 +99,7 @@ fn serve(
|
|||
let accepter = TlsAcceptor::new(config.clone(), incoming);
|
||||
let new_service = make_service_fn(move |socket: &TlsStream| {
|
||||
let remote_addr = socket.remote_addr();
|
||||
serv_func(remote_addr)
|
||||
serve_func(remote_addr)
|
||||
});
|
||||
let server = tokio::spawn(hyper::Server::builder(accepter).serve(new_service));
|
||||
handles.push(server);
|
||||
|
@ -111,7 +111,7 @@ fn serve(
|
|||
None => {
|
||||
let new_service = make_service_fn(move |socket: &AddrStream| {
|
||||
let remote_addr = socket.remote_addr();
|
||||
serv_func(remote_addr)
|
||||
serve_func(remote_addr)
|
||||
});
|
||||
let server = tokio::spawn(hyper::Server::builder(incoming).serve(new_service));
|
||||
handles.push(server);
|
||||
|
|
|
@ -64,7 +64,7 @@ fn allow_upload_delete_can_override(#[with(&["-A"])] server: TestServer) -> Resu
|
|||
fn allow_search(#[with(&["--allow-search"])] server: TestServer) -> Result<(), Error> {
|
||||
let resp = reqwest::blocking::get(format!("{}?q={}", server.url(), "test.html"))?;
|
||||
assert_eq!(resp.status(), 200);
|
||||
let paths = utils::retrive_index_paths(&resp.text()?);
|
||||
let paths = utils::retrieve_index_paths(&resp.text()?);
|
||||
assert!(!paths.is_empty());
|
||||
for p in paths {
|
||||
assert!(p.contains("test.html"));
|
||||
|
|
|
@ -15,11 +15,11 @@ pub type Error = Box<dyn std::error::Error>;
|
|||
#[allow(dead_code)]
|
||||
pub static FILES: &[&str] = &["test.txt", "test.html", "index.html", "😀.bin"];
|
||||
|
||||
/// Directory names for testing diretory don't exist
|
||||
/// Directory names for testing directory don't exist
|
||||
#[allow(dead_code)]
|
||||
pub static DIR_NO_FOUND: &str = "dir-no-found/";
|
||||
|
||||
/// Directory names for testing diretory don't have index.html
|
||||
/// Directory names for testing directory don't have index.html
|
||||
#[allow(dead_code)]
|
||||
pub static DIR_NO_INDEX: &str = "dir-no-index/";
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ use rstest::rstest;
|
|||
fn hidden_get_dir(#[case] server: TestServer, #[case] exist: bool) -> Result<(), Error> {
|
||||
let resp = reqwest::blocking::get(server.url())?;
|
||||
assert_eq!(resp.status(), 200);
|
||||
let paths = utils::retrive_index_paths(&resp.text()?);
|
||||
let paths = utils::retrieve_index_paths(&resp.text()?);
|
||||
assert_eq!(paths.contains(".git/"), exist);
|
||||
assert_eq!(paths.contains("index.html"), exist);
|
||||
Ok(())
|
||||
|
@ -34,7 +34,7 @@ fn hidden_propfind_dir(#[case] server: TestServer, #[case] exist: bool) -> Resul
|
|||
fn hidden_search_dir(#[case] server: TestServer, #[case] exist: bool) -> Result<(), Error> {
|
||||
let resp = reqwest::blocking::get(format!("{}?q={}", server.url(), "test.html"))?;
|
||||
assert_eq!(resp.status(), 200);
|
||||
let paths = utils::retrive_index_paths(&resp.text()?);
|
||||
let paths = utils::retrieve_index_paths(&resp.text()?);
|
||||
for p in paths {
|
||||
assert_eq!(p.contains("test.html"), exist);
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ fn head_dir_zip(server: TestServer) -> Result<(), Error> {
|
|||
fn get_dir_search(#[with(&["-A"])] server: TestServer) -> Result<(), Error> {
|
||||
let resp = reqwest::blocking::get(format!("{}?q={}", server.url(), "test.html"))?;
|
||||
assert_eq!(resp.status(), 200);
|
||||
let paths = utils::retrive_index_paths(&resp.text()?);
|
||||
let paths = utils::retrieve_index_paths(&resp.text()?);
|
||||
assert!(!paths.is_empty());
|
||||
for p in paths {
|
||||
assert!(p.contains("test.html"));
|
||||
|
@ -78,7 +78,7 @@ fn get_dir_search(#[with(&["-A"])] server: TestServer) -> Result<(), Error> {
|
|||
fn get_dir_search2(#[with(&["-A"])] server: TestServer) -> Result<(), Error> {
|
||||
let resp = reqwest::blocking::get(format!("{}?q={}", server.url(), "😀.bin"))?;
|
||||
assert_eq!(resp.status(), 200);
|
||||
let paths = utils::retrive_index_paths(&resp.text()?);
|
||||
let paths = utils::retrieve_index_paths(&resp.text()?);
|
||||
assert!(!paths.is_empty());
|
||||
for p in paths {
|
||||
assert!(p.contains("😀.bin"));
|
||||
|
|
|
@ -56,7 +56,7 @@ fn render_try_index3(#[with(&["--render-try-index"])] server: TestServer) -> Res
|
|||
fn render_try_index4(#[case] server: TestServer, #[case] searched: bool) -> Result<(), Error> {
|
||||
let resp = reqwest::blocking::get(format!("{}{}?q={}", server.url(), DIR_NO_INDEX, "😀.bin"))?;
|
||||
assert_eq!(resp.status(), 200);
|
||||
let paths = utils::retrive_index_paths(&resp.text()?);
|
||||
let paths = utils::retrieve_index_paths(&resp.text()?);
|
||||
assert!(!paths.is_empty());
|
||||
assert_eq!(paths.iter().all(|v| v.contains("😀.bin")), searched);
|
||||
Ok(())
|
||||
|
|
|
@ -20,7 +20,7 @@ fn default_not_allow_symlink(server: TestServer, tmpdir: TempDir) -> Result<(),
|
|||
let resp = reqwest::blocking::get(format!("{}{}/index.html", server.url(), dir))?;
|
||||
assert_eq!(resp.status(), 404);
|
||||
let resp = reqwest::blocking::get(server.url())?;
|
||||
let paths = utils::retrive_index_paths(&resp.text()?);
|
||||
let paths = utils::retrieve_index_paths(&resp.text()?);
|
||||
assert!(!paths.is_empty());
|
||||
assert!(!paths.contains(&format!("{}/", dir)));
|
||||
Ok(())
|
||||
|
@ -39,7 +39,7 @@ fn allow_symlink(
|
|||
let resp = reqwest::blocking::get(format!("{}{}/index.html", server.url(), dir))?;
|
||||
assert_eq!(resp.status(), 200);
|
||||
let resp = reqwest::blocking::get(server.url())?;
|
||||
let paths = utils::retrive_index_paths(&resp.text()?);
|
||||
let paths = utils::retrieve_index_paths(&resp.text()?);
|
||||
assert!(!paths.is_empty());
|
||||
assert!(paths.contains(&format!("{}/", dir)));
|
||||
Ok(())
|
||||
|
|
|
@ -9,7 +9,7 @@ macro_rules! assert_resp_paths {
|
|||
($resp:ident, $files:expr) => {
|
||||
assert_eq!($resp.status(), 200);
|
||||
let body = $resp.text()?;
|
||||
let paths = self::utils::retrive_index_paths(&body);
|
||||
let paths = self::utils::retrieve_index_paths(&body);
|
||||
assert!(!paths.is_empty());
|
||||
for file in $files {
|
||||
assert!(paths.contains(&file.to_string()));
|
||||
|
@ -25,8 +25,8 @@ macro_rules! fetch {
|
|||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn retrive_index_paths(index: &str) -> HashSet<String> {
|
||||
retrive_index_paths_impl(index).unwrap_or_default()
|
||||
pub fn retrieve_index_paths(index: &str) -> HashSet<String> {
|
||||
retrieve_index_paths_impl(index).unwrap_or_default()
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
|
@ -35,7 +35,7 @@ pub fn encode_uri(v: &str) -> String {
|
|||
parts.join("/")
|
||||
}
|
||||
|
||||
fn retrive_index_paths_impl(index: &str) -> Option<HashSet<String>> {
|
||||
fn retrieve_index_paths_impl(index: &str) -> Option<HashSet<String>> {
|
||||
let lines: Vec<&str> = index.lines().collect();
|
||||
let line = lines.iter().find(|v| v.contains("DATA ="))?;
|
||||
let value: Value = line[7..].parse().ok()?;
|
||||
|
|
Loading…
Reference in a new issue