cli: verify vscode server integrity before committing to cache (#191792)

Fixes #191469
This commit is contained in:
Connor Peet
2023-08-30 08:20:08 -07:00
committed by GitHub
parent ec9aa5cfdf
commit 5cc83f7994

View File

@@ -14,7 +14,7 @@ use crate::tunnels::paths::{get_server_folder_name, SERVER_FOLDER_NAME};
use crate::update_service::{
unzip_downloaded_release, Platform, Release, TargetKind, UpdateService,
};
use crate::util::command::{capture_command, kill_tree};
use crate::util::command::{capture_command, capture_command_and_check_status, kill_tree};
use crate::util::errors::{wrap, AnyError, CodeError, ExtensionInstallFailed, WrappedError};
use crate::util::http::{self, BoxedHttp};
use crate::util::io::SilentCopyProgress;
@@ -416,11 +416,23 @@ impl<'a> ServerBuilder<'a> {
)
.await?;
unzip_downloaded_release(
&archive_path,
&target_dir.join(SERVER_FOLDER_NAME),
SilentCopyProgress(),
)?;
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', " / ")
);
Ok(())
})