aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/filecounter.rs12
-rw-r--r--src/index.rs11
-rw-r--r--src/main.rs1
3 files changed, 5 insertions, 19 deletions
diff --git a/src/filecounter.rs b/src/filecounter.rs
deleted file mode 100644
index 3532fa3..0000000
--- a/src/filecounter.rs
+++ /dev/null
@@ -1,12 +0,0 @@
-use walkdir::*;
-
-/// Function to count the number of entries in a directory.
-/// Is needed to get a progress.
-pub fn filecount(path : &str) -> u64 {
- let mut counter : u64 = 0;
- for _ in WalkDir::new(path).into_iter().filter_map(|e| e.ok()) {
- counter += 1;
- }
-
- counter
-}
diff --git a/src/index.rs b/src/index.rs
index 92a12b6..332dece 100644
--- a/src/index.rs
+++ b/src/index.rs
@@ -41,7 +41,6 @@ impl Index {
}
pub fn generate(input_path : &str, callback : impl Fn(GenState, u8)) -> Self {
- let mut nof : usize = 0;
let num_threads = thread::available_parallelism().unwrap().get();
let mut paths = Vec::new();
let (result_tx, result_rx) = std::sync::mpsc::channel();
@@ -49,14 +48,14 @@ impl Index {
callback(GenState::Fetching, 0);
for entry in WalkDir::new(input_path)
.into_iter()
- .filter_map(|e| e.ok()) {
- if entry.path().is_file() && text::is_supported(entry.path().to_str().unwrap()) {
- nof += 1;
- paths.push(entry.path().to_str().unwrap().to_string());
- }
+ .filter_map(|e| e.ok()) {
+ if entry.path().is_file() && text::is_supported(entry.path().to_str().unwrap()) {
+ paths.push(entry.path().to_str().unwrap().to_string());
}
+ }
callback(GenState::Fetching, 100);
+ let nof = paths.len();
let chunks = paths.chunks(paths.len() / num_threads);
let mut filecache = Vec::with_capacity(nof);
diff --git a/src/main.rs b/src/main.rs
index 20697f7..22451ba 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -4,7 +4,6 @@ pub mod text;
pub mod splitter;
pub mod filecache;
pub mod searchresult;
-pub mod filecounter;
pub mod extractors;
pub mod index;
pub mod gui;