Skip to content

Commit

Permalink
Fix progress bar for unpacking
Browse files Browse the repository at this point in the history
  • Loading branch information
delsner committed Jun 7, 2024
1 parent af0f969 commit fefabe8
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/unpack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,10 @@ async fn create_prefix(channel_dir: &Path, target_prefix: &Path) -> Result<()> {
.map_err(|e| anyhow!("could not create temporary directory: {}", e))?
.into_path();

eprintln!("⏳ Installing {} packages...", packages.len());
eprintln!(
"⏳ Extracting and installing {} packages...",
packages.len()
);
let reporter = ProgressReporter::new(packages.len() as u64);

// extract packages to cache
Expand Down Expand Up @@ -204,17 +207,20 @@ async fn create_prefix(channel_dir: &Path, target_prefix: &Path) -> Result<()> {
)
.await
.map_err(|e| anyhow!("could not extract package: {}", e))?;
reporter.pb.inc(1);

Ok::<RepoDataRecord, anyhow::Error>(repodata_record)
}
})
.buffer_unordered(50)
.try_collect()
.await?;
reporter.pb.finish_and_clear();

// Invariant: all packages are in the cache
tracing::info!("Installing {} packages", repodata_records.len());
let installer = Installer::default().with_reporter(reporter);
let installer = Installer::default()
.with_reporter::<ProgressReporter>(ProgressReporter::new(repodata_records.len() as u64));
installer
.with_package_cache(package_cache)
.install(&target_prefix, repodata_records)
Expand Down

0 comments on commit fefabe8

Please sign in to comment.