Detect install_path & load metadata in block_in_place

since they involves blocking fs io.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2022-08-05 00:18:21 +10:00
parent b4c6db7cda
commit b8c44839c1
No known key found for this signature in database
GPG key ID: 591C0B03040416D6

View file

@ -322,6 +322,7 @@ async fn entry(jobserver_client: LazyJobserverClient) -> Result<()> {
let mut uithread = UIThread::new(!opts.no_confirm); let mut uithread = UIThread::new(!opts.no_confirm);
// Compute install directory // Compute install directory
let (install_path, metadata) = block_in_place(|| -> Result<_> {
let (install_path, custom_install_path) = get_install_path(opts.install_path.as_deref()); let (install_path, custom_install_path) = get_install_path(opts.install_path.as_deref());
let install_path = install_path.ok_or_else(|| { let install_path = install_path.ok_or_else(|| {
error!("No viable install path found of specified, try `--install-path`"); error!("No viable install path found of specified, try `--install-path`");
@ -333,11 +334,14 @@ async fn entry(jobserver_client: LazyJobserverClient) -> Result<()> {
// Load metadata // Load metadata
let metadata = if !custom_install_path { let metadata = if !custom_install_path {
debug!("Reading binstall/crates-v1.json"); debug!("Reading binstall/crates-v1.json");
Some(block_in_place(metafiles::binstall_v1::Records::load)?) Some(metafiles::binstall_v1::Records::load()?)
} else { } else {
None None
}; };
Ok((install_path, metadata))
})?;
// Remove installed crates // Remove installed crates
let crate_names = CrateName::dedup(crate_names).filter(|crate_name| { let crate_names = CrateName::dedup(crate_names).filter(|crate_name| {
if opts.force { if opts.force {