From 3755eb6bd7a32d837c21e24472dd0ac53b07d858 Mon Sep 17 00:00:00 2001 From: Truman Kilen Date: Fri, 7 Apr 2023 22:26:20 -0500 Subject: [PATCH] Fix progress bar not visually completing --- repak_cli/src/main.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/repak_cli/src/main.rs b/repak_cli/src/main.rs index f54833d..576ded5 100644 --- a/repak_cli/src/main.rs +++ b/repak_cli/src/main.rs @@ -239,13 +239,9 @@ fn unpack(aes_key: Option, action: ActionUnpack) -> Result<(), repa .filter_map(|e| e.transpose()) .collect::, repak::Error>>()?; - use indicatif::ParallelProgressIterator; - - let iter = entries - .par_iter() - .progress_with_style(indicatif::ProgressStyle::with_template(STYLE).unwrap()); - let progress = iter.progress.clone(); - iter.try_for_each_init( + let progress = indicatif::ProgressBar::new(entries.len() as u64) + .with_style(indicatif::ProgressStyle::with_template(STYLE).unwrap()); + entries.par_iter().try_for_each_init( || (progress.clone(), File::open(&action.input)), |(progress, file), entry| -> Result<(), repak::Error> { if action.verbose { @@ -256,9 +252,12 @@ fn unpack(aes_key: Option, action: ActionUnpack) -> Result<(), repa &entry.entry_path, &mut BufReader::new(file.as_ref().unwrap()), // TODO: avoid this unwrap &mut fs::File::create(&entry.out_path)?, - ) + )?; + progress.inc(1); + Ok(()) }, )?; + progress.finish(); println!("Unpacked {} files to {}", entries.len(), output.display());