aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRuben Beltran del Rio <ruben@unlimited.pizza>2023-04-16 11:26:24 +0200
committerRuben Beltran del Rio <ruben@unlimited.pizza>2023-04-16 11:26:24 +0200
commit5643a0416ded5e5135a968cb57a279568b471248 (patch)
tree163e9c9b03eecb3ef52d05bb3c504da35a3339e1 /src
parent102a4884c3d7d26817fefb38c675be07047f5ee2 (diff)
Ignore hidden files in root
Diffstat (limited to 'src')
-rw-r--r--src/file_finder.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/file_finder.rs b/src/file_finder.rs
index fc32fa9..598f868 100644
--- a/src/file_finder.rs
+++ b/src/file_finder.rs
@@ -3,16 +3,21 @@ use std::fs::read_dir;
use std::path::PathBuf;
pub fn find_files(directory_path: PathBuf) -> Vec<File> {
+ return find_files_recursively(&directory_path, &directory_path);
+}
+
+fn find_files_recursively(root_path: &PathBuf, directory_path: &PathBuf) -> Vec<File> {
let mut result: Vec<File> = vec![];
let file_handler = FileHandler::default();
- let entries = read_dir(directory_path).unwrap();
+ let entries = read_dir(&directory_path).unwrap();
for entry in entries {
let path = entry.unwrap().path();
- if path.starts_with(".") && !path.starts_with(".well-known") {
+ let relative_path = path.strip_prefix(&root_path).unwrap();
+ if relative_path.starts_with(".") && !relative_path.starts_with(".well-known") {
continue;
}
if path.is_dir() {
- result.append(&mut find_files(path))
+ result.append(&mut find_files_recursively(&root_path, &path))
} else {
let file_type = file_handler.identify(&path);
result.push(File {