From a35db557eaf2e80014265483b3f6fe701a6e2632 Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Thu, 23 Jun 2022 19:48:03 +1000 Subject: [PATCH] Run "Install binaries" step in `block_in_place` mode Since they execute a lot of blocking fs operations. Signed-off-by: Jiahao XU --- src/main.rs | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/src/main.rs b/src/main.rs index 39e832e0..169e74d7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,7 +12,11 @@ use log::{debug, error, info, warn, LevelFilter}; use miette::{miette, IntoDiagnostic, Result, WrapErr}; use simplelog::{ColorChoice, ConfigBuilder, TermLogger, TerminalMode}; 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::{ bins, @@ -441,26 +445,28 @@ async fn install_from_package( uithread.confirm().await?; info!("Installing binaries..."); - for file in &bin_files { - file.install_bin()?; - } - - // Generate symlinks - if !opts.no_symlinks { + block_in_place(|| { for file in &bin_files { - file.install_link()?; + file.install_bin()?; } - } - 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}"); - }); - } + // Generate symlinks + if !opts.no_symlinks { + for file in &bin_files { + file.install_link()?; + } + } - 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(