Skip to content

Commit

Permalink
cli: skip integrity check when prereq skip flag is present (#203912) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
connor4312 authored Jan 31, 2024
1 parent 0504748 commit f5442d1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 19 deletions.
33 changes: 19 additions & 14 deletions cli/src/tunnels/code_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(())
})
Expand Down
16 changes: 11 additions & 5 deletions cli/src/util/prereqs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}

Expand Down Expand Up @@ -55,7 +54,7 @@ impl PreReqChecker {
pub async fn verify(&self) -> Result<Platform, CodeError> {
let (is_nixos, skip_glibc_checks, or_musl) = tokio::join!(
check_is_nixos(),
check_skip_req_file(),
skip_requirements_check(),
check_musl_interpreter()
);

Expand Down Expand Up @@ -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)]
Expand Down

0 comments on commit f5442d1

Please sign in to comment.