From 380a7162001272246f3d7c240b68f15cad251856 Mon Sep 17 00:00:00 2001 From: daimond113 <72147841+daimond113@users.noreply.github.com> Date: Thu, 16 Jan 2025 20:18:10 +0100 Subject: [PATCH] feat(engines): report version resolving Improves user experience when running engines by reporting that it is currently resolving the version of the engine to download. --- src/cli/version.rs | 50 +++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/cli/version.rs b/src/cli/version.rs index 5ed0641..1d3fb69 100644 --- a/src/cli/version.rs +++ b/src/cli/version.rs @@ -193,33 +193,21 @@ pub async fn get_or_download_engine( .with_extension(std::env::consts::EXE_EXTENSION)); } - let mut versions = source - .resolve( - &req, - &ResolveOptions { - reqwest: reqwest.clone(), - }, - ) - .await - .context("failed to resolve versions")?; - let (version, engine_ref) = versions.pop_last().context("no matching versions found")?; - - let path = path.join(version.to_string()); - - fs::create_dir_all(&path) - .await - .context("failed to create engine container folder")?; - - let path = path - .join(source.expected_file_name()) - .with_extension(std::env::consts::EXE_EXTENSION); - - let mut file = fs::File::create(&path) - .await - .context("failed to create new file")?; - run_with_reporter(|_, root_progress, reporter| async { let root_progress = root_progress; + let reporter = reporter; + + root_progress.set_message("resolve version"); + let mut versions = source + .resolve( + &req, + &ResolveOptions { + reqwest: reqwest.clone(), + }, + ) + .await + .context("failed to resolve versions")?; + let (version, engine_ref) = versions.pop_last().context("no matching versions found")?; root_progress.set_message("download"); @@ -237,6 +225,18 @@ pub async fn get_or_download_engine( .await .context("failed to download engine")?; + let path = path.join(version.to_string()); + fs::create_dir_all(&path) + .await + .context("failed to create engine container folder")?; + let path = path + .join(source.expected_file_name()) + .with_extension(std::env::consts::EXE_EXTENSION); + + let mut file = fs::File::create(&path) + .await + .context("failed to create new file")?; + tokio::io::copy( &mut archive .find_executable(source.expected_file_name())