aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2023-07-26 23:00:30 +0200
committerNathan Reiner <nathan@nathanreiner.xyz>2023-07-26 23:00:30 +0200
commit6c7935ff4589adc92459185f3e9d1f47c76af1ed (patch)
tree29cfe8e502141ba54a396c937cad2a3129029cbe
parente7b6cd99cc1d546690a20006b556ae9328eb2005 (diff)
only push supported files to processing queue
-rw-r--r--src/index.rs2
-rw-r--r--src/text/mod.rs6
2 files changed, 7 insertions, 1 deletions
diff --git a/src/index.rs b/src/index.rs
index d3aab9e..92a12b6 100644
--- a/src/index.rs
+++ b/src/index.rs
@@ -50,7 +50,7 @@ impl Index {
for entry in WalkDir::new(input_path)
.into_iter()
.filter_map(|e| e.ok()) {
- if entry.path().is_file() {
+ if entry.path().is_file() && text::is_supported(entry.path().to_str().unwrap()) {
nof += 1;
paths.push(entry.path().to_str().unwrap().to_string());
}
diff --git a/src/text/mod.rs b/src/text/mod.rs
index c3fd8f6..ac474bc 100644
--- a/src/text/mod.rs
+++ b/src/text/mod.rs
@@ -44,3 +44,9 @@ pub fn extract_text(path : &str) -> String {
let extenstion = p.extension().unwrap_or_else(|| OsStr::new("")).to_str().unwrap();
EXT.get(extenstion).unwrap_or(&(empty_extractor as ExtFn))(path)
}
+
+pub fn is_supported(path : &str) -> bool {
+ let p = Path::new(&path);
+ let extenstion = p.extension().unwrap_or_else(|| OsStr::new("")).to_str().unwrap();
+ EXT.get(extenstion).is_some()
+}