Projects STRLCPY deduplicator Commits a65e2226
🤬
  • ■ ■ ■ ■ ■ ■
    src/output.rs
    skipped 5 lines
    6 6  use colored::Colorize;
    7 7  use dashmap::DashMap;
    8 8  use indicatif::{ProgressBar, ProgressIterator, ProgressStyle};
     9 +use itertools::Itertools;
    9 10  use prettytable::{format, row, Table};
    10 11  use std::io::Write;
    11 12  use std::path::Path;
     13 +use std::time::Duration;
    12 14  use std::{fs, io};
    13 15  use unicode_segmentation::UnicodeSegmentation;
    14  -use itertools::Itertools;
    15 16   
    16 17  fn format_path(path: &Path, opts: &Params) -> Result<String> {
    17 18   let display_path = path
    skipped 140 lines
    158 159   
    159 160   let mut output_table = Table::new();
    160 161   let progress_bar = ProgressBar::new(duplicates.len() as u64);
     162 + progress_bar.enable_steady_tick(Duration::from_millis(50));
    161 163   let progress_style = ProgressStyle::default_bar()
    162 164   .template("{spinner:.green} [generating output] [{wide_bar:.cyan/blue}] {pos}/{len} files")
    163 165   .unwrap();
    skipped 21 lines
    185 187   output_table.printstd();
    186 188  }
    187 189   
     190 +#[allow(unused)]
     191 +pub fn raw(duplicates: DashMap<String, Vec<File>>, opts: &Params) -> Result<()> {
     192 + if duplicates.is_empty() {
     193 + println!(
     194 + "\n{}",
     195 + "No duplicates found matching your search criteria.".green()
     196 + );
     197 + return Ok(());
     198 + }
     199 + 
     200 + duplicates
     201 + .into_iter()
     202 + .sorted_unstable_by_key(|(_, f)| f.first().and_then(|ff| ff.size).unwrap_or_default())
     203 + .for_each(|(_hash, group)| {
     204 + group.iter().for_each(|file| {
     205 + println!(
     206 + "{}\t{}\t{}",
     207 + format_path(&file.path, opts).unwrap_or_default().blue(),
     208 + file_size(file).unwrap_or_default().red(),
     209 + modified_time(&file.path).unwrap_or_default().yellow()
     210 + )
     211 + });
     212 + 
     213 + println!("---");
     214 + });
     215 + 
     216 + Ok(())
     217 +}
     218 + 
  • ■ ■ ■ ■ ■ ■
    src/scanner.rs
    skipped 47 lines
    48 48   let progress_style =
    49 49   ProgressStyle::with_template("{spinner:.green} [mapping paths] {pos} paths")?;
    50 50   progress.set_style(progress_style);
    51  - progress.enable_steady_tick(Duration::from_millis(100));
     51 + progress.enable_steady_tick(Duration::from_millis(50));
    52 52   
    53 53   let files = walker
    54 54   .progress_with(progress)
    55 55   .filter_map(Result::ok)
    56 56   .map(|file| file.into_path())
    57 57   .filter(|fpath| fpath.is_file())
    58  - .collect::<Vec<PathBuf>>()
     58 + .collect::<Vec<PathBuf>>();
     59 + 
     60 + let scan_progress = ProgressBar::new(files.len() as u64);
     61 + let scan_progress_style = ProgressStyle::with_template(
     62 + "{spinner:.green} [processing mapped paths] [{wide_bar:.cyan/blue}] {pos}/{len} files",
     63 + )?;
     64 + scan_progress.set_style(scan_progress_style);
     65 + scan_progress.enable_steady_tick(Duration::from_millis(50));
     66 + 
     67 + let scan_results = files
    59 68   .into_par_iter()
    60  - .progress_with_style(ProgressStyle::with_template(
    61  - "{spinner:.green} [processing mapped paths] [{wide_bar:.cyan/blue}] {pos}/{len} files",
    62  - )?)
     69 + .progress_with(scan_progress)
    63 70   .map(|fpath| File {
    64 71   path: fpath.clone(),
    65 72   hash: None,
    skipped 6 lines
    72 79   .filter(|file| filters::is_file_gt_min_size(app_opts, file))
    73 80   .collect();
    74 81   
    75  - Ok(files)
     82 + Ok(scan_results)
    76 83  }
    77 84   
    78 85  fn process_file_index(
    skipped 23 lines
    102 109   index_criteria: IndexCritera,
    103 110  ) -> Result<DashMap<String, Vec<File>>> {
    104 111   let store: DashMap<String, Vec<File>> = DashMap::new();
     112 + let index_progress = ProgressBar::new(files.len() as u64);
     113 + let index_progress_style = ProgressStyle::with_template(
     114 + "{spinner:.green} [indexing files] [{wide_bar:.cyan/blue}] {pos}/{len} files",
     115 + )?;
     116 + index_progress.set_style(index_progress_style);
     117 + index_progress.enable_steady_tick(Duration::from_millis(50));
     118 + 
    105 119   files
    106 120   .into_par_iter()
    107  - .progress_with_style(ProgressStyle::with_template(
    108  - "{spinner:.green} [indexing files] [{wide_bar:.cyan/blue}] {pos}/{len} files",
    109  - )?)
     121 + .progress_with(index_progress)
    110 122   .for_each(|file| process_file_index(file, &store, index_criteria));
    111 123   
    112 124   Ok(store)
    skipped 28 lines
Please wait...
Page is in error, reload to recover