mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-05-07 20:50:03 +00:00
Use download_and_extract
in fetchers
to improve efficiency by avoiding disk io (except for `PkgFmt::Zip` and `PkgFmt::Bin`) and run the compresser in parallel to the downloader. Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
b6bfd40c3a
commit
c9b0d45a24
4 changed files with 19 additions and 24 deletions
27
src/main.rs
27
src/main.rs
|
@ -361,11 +361,21 @@ async fn install_from_package(
|
|||
meta.bin_dir = "{ bin }{ binary-ext }".to_string();
|
||||
}
|
||||
|
||||
let bin_path = temp_dir.path().join(format!("bin-{}", opts.name));
|
||||
debug!("Using temporary binary path: {}", bin_path.display());
|
||||
|
||||
// Download package
|
||||
if opts.dry_run {
|
||||
info!("Dry run, not downloading package");
|
||||
} else {
|
||||
fetcher.fetch(&pkg_path).await?;
|
||||
fetcher.fetch_and_extract(&bin_path).await?;
|
||||
|
||||
if binaries.is_empty() {
|
||||
error!("No binaries specified (or inferred from file system)");
|
||||
return Err(miette!(
|
||||
"No binaries specified (or inferred from file system)"
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(incomplete)]
|
||||
|
@ -392,21 +402,6 @@ async fn install_from_package(
|
|||
}
|
||||
}
|
||||
|
||||
let bin_path = temp_dir.path().join(format!("bin-{}", opts.name));
|
||||
debug!("Using temporary binary path: {}", bin_path.display());
|
||||
|
||||
if !opts.dry_run {
|
||||
// Extract files
|
||||
extract(&pkg_path, fetcher.pkg_fmt(), &bin_path)?;
|
||||
|
||||
if binaries.is_empty() {
|
||||
error!("No binaries specified (or inferred from file system)");
|
||||
return Err(miette!(
|
||||
"No binaries specified (or inferred from file system)"
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
// List files to be installed
|
||||
// based on those found via Cargo.toml
|
||||
let bin_data = bins::Data {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue