From c5621212bcba45c9b479670c90a85e13c99f0ca6 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sat, 19 Oct 2024 16:35:45 -0400 Subject: [PATCH] Using multi-level deep folders successfully but the output is still shallow. --- src/command/build/runner.rs | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/command/build/runner.rs b/src/command/build/runner.rs index 9b9b8c3..368f57b 100644 --- a/src/command/build/runner.rs +++ b/src/command/build/runner.rs @@ -86,24 +86,19 @@ async fn filter_to_highest_folders_containing_org_files( } async fn get_post_directories(config: &Config) -> Result, CustomError> { + if !config.get_posts_directory().exists() { + return Ok(Vec::new()); + } + let top_level_org_folders = walk_fs( config.get_posts_directory(), filter_to_highest_folders_containing_org_files, ) .await?; - - let mut ret = Vec::new(); - if !config.get_posts_directory().exists() { - return Ok(ret); - } - let mut entries = tokio::fs::read_dir(config.get_posts_directory()).await?; - while let Some(entry) = entries.next_entry().await? { - let file_type = entry.file_type().await?; - if file_type.is_dir() { - ret.push(entry.path()); - } - } - Ok(ret) + Ok(top_level_org_folders + .into_iter() + .map(|entry| entry.path()) + .collect()) } async fn load_blog_posts(config: &Config) -> Result, CustomError> {