cache filetree
This commit is contained in:
parent
a5240fea57
commit
182b17c47f
1 changed files with 11 additions and 1 deletions
|
@ -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<FileNode> = 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,
|
||||
|
|
Loading…
Reference in a new issue