diff --git a/src/utils/routes/cours.rs b/src/utils/routes/cours.rs index 3259bbd..33ce89e 100644 --- a/src/utils/routes/cours.rs +++ b/src/utils/routes/cours.rs @@ -1,5 +1,6 @@ use std::{cmp::Ordering, path::Path}; +use cached::proc_macro::once; use regex::Regex; use serde::Serialize; @@ -29,10 +30,19 @@ impl PartialOrd for FileNode { } } +#[once(time = 120)] pub fn get_filetree( dir_path: &str, exclusion_list: &[String], exclusion_patterns: &[Regex], +) -> FileNode { + gen_filetree(dir_path, exclusion_list, exclusion_patterns) +} + +fn gen_filetree( + dir_path: &str, + exclusion_list: &[String], + exclusion_patterns: &[Regex], ) -> FileNode { let mut children: Vec = std::fs::read_dir(dir_path) .unwrap() @@ -54,7 +64,7 @@ pub fn get_filetree( }) } else { // Exclude empty directories - let children_of_children = get_filetree( + let children_of_children = gen_filetree( entry_path.to_str().unwrap(), exclusion_list, exclusion_patterns,