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