From 3ca9adc0c5e138271dacab7691dac77da0ba0f21 Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Thu, 6 Jul 2023 10:42:52 +0200 Subject: fix progressbar --- src/main.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index 5275321..3cae322 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,8 +27,14 @@ fn generate_index(input_path : &str, index_path : &str) { let mut nof_handle : Option<_> = Some(s.spawn(|| filecount(input_path))); for entry in WalkDir::new(input_path).into_iter().filter_map(|e| e.ok()) { + counter += 1; if entry.path().is_file() { let content : String = text::extract_text(entry.path().to_str().unwrap()); + + if content.is_empty() { + continue + } + let words : Vec = splitter::split_to_words(content); for word in words.iter() { @@ -38,8 +44,6 @@ fn generate_index(input_path : &str, index_path : &str) { let fv = dict.vectorize_word_list(words.clone()); writeln!(index_file, "{}, {}", entry.path().to_str().unwrap().replace(",", "\0"), fv.to_hex()).ok(); - counter += 1; - match nof_handle { Some(t) => { @@ -47,14 +51,14 @@ fn generate_index(input_path : &str, index_path : &str) { nof_handle = None; } None => { - print!("\r\x1b[2K{} of {} files indexed ({}%)", counter, nof, (counter * 100) / nof); + eprint!("\r\x1b[2K{} of {} files indexed ({}%)", counter, nof, (counter * 100) / nof); std::io::stdout().flush().ok(); } } } } - println!("\r\x1b[2K{} of {} files indexed ({}%)", counter, nof, (counter * 100) / nof); + eprintln!("\r\x1b[2Kall files indexed (100%)"); let dict_list : Vec = dict.to_list(); writeln!(index_file, "#{}", dict_list.join(",")).ok(); @@ -105,6 +109,6 @@ fn search(index_path : &str, search_args : Vec<&str>) { fn main() { println!("Generating Index..."); generate_index("/home/n8", "index.idxs"); - //println!("Searching..."); - //search("index.idxs", vec!["one", "difficult", "under", "linux"]); + println!("Searching..."); + search("index.idxs", vec!["welt"]); } -- cgit v1.2.3-70-g09d2