From af1a0788252fde2226ab6c6961e06c73663a949c Mon Sep 17 00:00:00 2001 From: Connor Peet Date: Wed, 31 Jan 2024 09:18:01 -0800 Subject: [PATCH] cli: skip integrity check when prereq skip flag is present --- cli/src/tunnels/code_server.rs | 33 +++++++++++++++++++-------------- cli/src/util/prereqs.rs | 16 +++++++++++----- 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/cli/src/tunnels/code_server.rs b/cli/src/tunnels/code_server.rs index 27d8bed1845a0..bb854001d541f 100644 --- a/cli/src/tunnels/code_server.rs +++ b/cli/src/tunnels/code_server.rs @@ -21,6 +21,7 @@ use crate::util::errors::{wrap, AnyError, CodeError, ExtensionInstallFailed, Wra use crate::util::http::{self, BoxedHttp}; use crate::util::io::SilentCopyProgress; use crate::util::machine::process_exists; +use crate::util::prereqs::skip_requirements_check; use crate::{debug, info, log, spanf, trace, warning}; use lazy_static::lazy_static; use opentelemetry::KeyValue; @@ -425,20 +426,24 @@ impl<'a> ServerBuilder<'a> { let server_dir = target_dir.join(SERVER_FOLDER_NAME); unzip_downloaded_release(&archive_path, &server_dir, SilentCopyProgress())?; - let output = capture_command_and_check_status( - server_dir - .join("bin") - .join(self.server_params.release.quality.server_entrypoint()), - &["--version"], - ) - .await - .map_err(|e| wrap(e, "error checking server integrity"))?; - - trace!( - self.logger, - "Server integrity verified, version: {}", - String::from_utf8_lossy(&output.stdout).replace('\n', " / ") - ); + if !skip_requirements_check().await { + let output = capture_command_and_check_status( + server_dir + .join("bin") + .join(self.server_params.release.quality.server_entrypoint()), + &["--version"], + ) + .await + .map_err(|e| wrap(e, "error checking server integrity"))?; + + trace!( + self.logger, + "Server integrity verified, version: {}", + String::from_utf8_lossy(&output.stdout).replace('\n', " / ") + ); + } else { + info!(self.logger, "Skipping server integrity check"); + } Ok(()) }) diff --git a/cli/src/util/prereqs.rs b/cli/src/util/prereqs.rs index 4f2a6ada8bb77..3bf2934e25542 100644 --- a/cli/src/util/prereqs.rs +++ b/cli/src/util/prereqs.rs @@ -25,7 +25,6 @@ lazy_static! { } const NIXOS_TEST_PATH: &str = "/etc/NIXOS"; -const SKIP_REQ_FILE: &str = "/tmp/vscode-skip-server-requirements-check"; pub struct PreReqChecker {} @@ -55,7 +54,7 @@ impl PreReqChecker { pub async fn verify(&self) -> Result { let (is_nixos, skip_glibc_checks, or_musl) = tokio::join!( check_is_nixos(), - check_skip_req_file(), + skip_requirements_check(), check_musl_interpreter() ); @@ -169,9 +168,16 @@ async fn check_is_nixos() -> bool { /// Provides a way to skip the server glibc requirements check from /// outside the install flow. A system process can create this /// file before the server is downloaded and installed. -#[allow(dead_code)] -async fn check_skip_req_file() -> bool { - fs::metadata(SKIP_REQ_FILE).await.is_ok() +#[cfg(not(windows))] +pub async fn skip_requirements_check() -> bool { + fs::metadata("/tmp/vscode-skip-server-requirements-check") + .await + .is_ok() +} + +#[cfg(windows)] +pub async fn skip_requirements_check() -> bool { + false } #[allow(dead_code)]