feat: skip directory walking in HEAD requests (#701)

This commit is contained in:
sigoden
2026-04-30 19:55:57 +08:00
committed by GitHub
parent 8e90ffa9c8
commit 82a8865b9f
+5 -4
View File
@@ -579,7 +579,7 @@ impl Server {
res: &mut Response, res: &mut Response,
) -> Result<()> { ) -> Result<()> {
let mut paths = vec![]; let mut paths = vec![];
if exist { if !head_only && exist {
paths = match self.list_dir(path, path, access_paths.clone()).await { paths = match self.list_dir(path, path, access_paths.clone()).await {
Ok(paths) => paths, Ok(paths) => paths,
Err(_) => { Err(_) => {
@@ -618,14 +618,15 @@ impl Server {
return self return self
.handle_ls_dir(path, true, query_params, head_only, user, access_paths, res) .handle_ls_dir(path, true, query_params, head_only, user, access_paths, res)
.await; .await;
} else { }
if !head_only {
let path_buf = path.to_path_buf(); let path_buf = path.to_path_buf();
let hidden = Arc::new(self.args.hidden.to_vec()); let hidden = Arc::new(self.args.hidden.to_vec());
let search = search.clone(); let search = search.clone();
let access_paths = access_paths.clone();
let search_paths = tokio::spawn(collect_dir_entries( let search_paths = tokio::spawn(collect_dir_entries(
access_paths, access_paths.clone(),
self.running.clone(), self.running.clone(),
path_buf, path_buf,
hidden, hidden,