From a53411b4d67915a5e0c273823a3027d87cb9b2d2 Mon Sep 17 00:00:00 2001 From: sigoden Date: Thu, 15 Jun 2023 08:28:21 +0800 Subject: [PATCH] fix: search should ignore entry path (#235) --- src/server.rs | 2 ++ tests/http.rs | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/src/server.rs b/src/server.rs index dba58b0..71af746 100644 --- a/src/server.rs +++ b/src/server.rs @@ -493,6 +493,7 @@ impl Server { let mut paths: Vec = vec![]; for dir in access_paths.leaf_paths(&path_buf) { let mut it = WalkDir::new(&dir).into_iter(); + it.next(); while let Some(Ok(entry)) = it.next() { if !running.load(Ordering::SeqCst) { break; @@ -1333,6 +1334,7 @@ async fn zip_dir( let mut paths: Vec = vec![]; for dir in access_paths.leaf_paths(&dir_clone) { let mut it = WalkDir::new(&dir).into_iter(); + it.next(); while let Some(Ok(entry)) = it.next() { if !running.load(Ordering::SeqCst) { break; diff --git a/tests/http.rs b/tests/http.rs index cc2e295..9c0d464 100644 --- a/tests/http.rs +++ b/tests/http.rs @@ -123,6 +123,15 @@ fn get_dir_search3(#[with(&["-A"])] server: TestServer) -> Result<(), Error> { Ok(()) } +#[rstest] +fn get_dir_search4(#[with(&["-A"])] server: TestServer) -> Result<(), Error> { + let resp = reqwest::blocking::get(format!("{}dir1?q=dir1&simple", server.url()))?; + assert_eq!(resp.status(), 200); + let text = resp.text().unwrap(); + assert!(text.is_empty()); + Ok(()) +} + #[rstest] fn head_dir_search(#[with(&["-A"])] server: TestServer) -> Result<(), Error> { let resp = fetch!(b"HEAD", format!("{}?q={}", server.url(), "test.html")).send()?;