mirror of
https://github.com/sreedevk/deduplicator.git
synced 2026-09-01 04:55:33 +00:00
stabilize ui progress bars
This commit is contained in:
@@ -48,18 +48,25 @@ fn scan(app_opts: &Params) -> Result<Vec<File>> {
|
||||
let progress_style =
|
||||
ProgressStyle::with_template("{spinner:.green} [mapping paths] {pos} paths")?;
|
||||
progress.set_style(progress_style);
|
||||
progress.enable_steady_tick(Duration::from_millis(100));
|
||||
progress.enable_steady_tick(Duration::from_millis(50));
|
||||
|
||||
let files = walker
|
||||
.progress_with(progress)
|
||||
.filter_map(Result::ok)
|
||||
.map(|file| file.into_path())
|
||||
.filter(|fpath| fpath.is_file())
|
||||
.collect::<Vec<PathBuf>>()
|
||||
.collect::<Vec<PathBuf>>();
|
||||
|
||||
let scan_progress = ProgressBar::new(files.len() as u64);
|
||||
let scan_progress_style = ProgressStyle::with_template(
|
||||
"{spinner:.green} [processing mapped paths] [{wide_bar:.cyan/blue}] {pos}/{len} files",
|
||||
)?;
|
||||
scan_progress.set_style(scan_progress_style);
|
||||
scan_progress.enable_steady_tick(Duration::from_millis(50));
|
||||
|
||||
let scan_results = files
|
||||
.into_par_iter()
|
||||
.progress_with_style(ProgressStyle::with_template(
|
||||
"{spinner:.green} [processing mapped paths] [{wide_bar:.cyan/blue}] {pos}/{len} files",
|
||||
)?)
|
||||
.progress_with(scan_progress)
|
||||
.map(|fpath| File {
|
||||
path: fpath.clone(),
|
||||
hash: None,
|
||||
@@ -72,7 +79,7 @@ fn scan(app_opts: &Params) -> Result<Vec<File>> {
|
||||
.filter(|file| filters::is_file_gt_min_size(app_opts, file))
|
||||
.collect();
|
||||
|
||||
Ok(files)
|
||||
Ok(scan_results)
|
||||
}
|
||||
|
||||
fn process_file_index(
|
||||
@@ -102,11 +109,16 @@ fn index_files(
|
||||
index_criteria: IndexCritera,
|
||||
) -> Result<DashMap<String, Vec<File>>> {
|
||||
let store: DashMap<String, Vec<File>> = DashMap::new();
|
||||
let index_progress = ProgressBar::new(files.len() as u64);
|
||||
let index_progress_style = ProgressStyle::with_template(
|
||||
"{spinner:.green} [indexing files] [{wide_bar:.cyan/blue}] {pos}/{len} files",
|
||||
)?;
|
||||
index_progress.set_style(index_progress_style);
|
||||
index_progress.enable_steady_tick(Duration::from_millis(50));
|
||||
|
||||
files
|
||||
.into_par_iter()
|
||||
.progress_with_style(ProgressStyle::with_template(
|
||||
"{spinner:.green} [indexing files] [{wide_bar:.cyan/blue}] {pos}/{len} files",
|
||||
)?)
|
||||
.progress_with(index_progress)
|
||||
.for_each(|file| process_file_index(file, &store, index_criteria));
|
||||
|
||||
Ok(store)
|
||||
|
||||
Reference in New Issue
Block a user