mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-05-06 04:00:02 +00:00
Run "Install binaries" step in block_in_place
mode
Since they execute a lot of blocking fs operations. Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
cc8144e06d
commit
a35db557ea
1 changed files with 23 additions and 17 deletions
40
src/main.rs
40
src/main.rs
|
@ -12,7 +12,11 @@ use log::{debug, error, info, warn, LevelFilter};
|
||||||
use miette::{miette, IntoDiagnostic, Result, WrapErr};
|
use miette::{miette, IntoDiagnostic, Result, WrapErr};
|
||||||
use simplelog::{ColorChoice, ConfigBuilder, TermLogger, TerminalMode};
|
use simplelog::{ColorChoice, ConfigBuilder, TermLogger, TerminalMode};
|
||||||
use tempfile::TempDir;
|
use tempfile::TempDir;
|
||||||
use tokio::{process::Command, runtime::Runtime, task::JoinError};
|
use tokio::{
|
||||||
|
process::Command,
|
||||||
|
runtime::Runtime,
|
||||||
|
task::{block_in_place, JoinError},
|
||||||
|
};
|
||||||
|
|
||||||
use cargo_binstall::{
|
use cargo_binstall::{
|
||||||
bins,
|
bins,
|
||||||
|
@ -441,26 +445,28 @@ async fn install_from_package(
|
||||||
uithread.confirm().await?;
|
uithread.confirm().await?;
|
||||||
|
|
||||||
info!("Installing binaries...");
|
info!("Installing binaries...");
|
||||||
for file in &bin_files {
|
block_in_place(|| {
|
||||||
file.install_bin()?;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate symlinks
|
|
||||||
if !opts.no_symlinks {
|
|
||||||
for file in &bin_files {
|
for file in &bin_files {
|
||||||
file.install_link()?;
|
file.install_bin()?;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if opts.no_cleanup {
|
// Generate symlinks
|
||||||
let _ = temp_dir.into_path();
|
if !opts.no_symlinks {
|
||||||
} else {
|
for file in &bin_files {
|
||||||
temp_dir.close().unwrap_or_else(|err| {
|
file.install_link()?;
|
||||||
warn!("Failed to clean up some resources: {err}");
|
}
|
||||||
});
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
if opts.no_cleanup {
|
||||||
|
let _ = temp_dir.into_path();
|
||||||
|
} else {
|
||||||
|
temp_dir.close().unwrap_or_else(|err| {
|
||||||
|
warn!("Failed to clean up some resources: {err}");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn install_from_source(
|
async fn install_from_source(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue