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:
Jiahao XU 2022-06-23 19:48:03 +10:00
parent cc8144e06d
commit a35db557ea
No known key found for this signature in database
GPG key ID: 591C0B03040416D6

View file

@ -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(