From a70f5e6100a0d91a4b05a40cb4d5e5b7f1d790e5 Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Sun, 27 Dec 2020 12:18:05 -0800 Subject: [PATCH] Use async version of read_dir --- src/main.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index f6cc829..e91b3a9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -228,13 +228,14 @@ async fn send_header(stream: &mut W, status: &str, meta: &[&st async fn list_directory(stream: &mut W, path: &Path) -> Result { log::info!("Listing directory {:?}", path); send_text_gemini_header(stream).await?; - for entry in std::fs::read_dir(path)? { + let mut entries = async_std::fs::read_dir(path).await?; + while let Some(entry) = entries.next().await { let entry = entry?; let mut name = entry.file_name().into_string().or(Err("Non-Unicode filename"))?; if name.starts_with('.') { continue; } - if entry.file_type()?.is_dir() { + if entry.file_type().await?.is_dir() { name += "/"; } stream.write_all(b"=> ").await?;