Include executable path and config path in version info
Use that to decide if the running version is equivalent to the newly spawning one when deciding if we can route a command to it or spawn a new gui
This commit is contained in:
1 parent
fc5c435949
commit
aa648797ae
4 files changed
+34
-8
No files matched your search
+4
-1
@@ -26,6 +26,7 @@ use smol::prelude::*;
|
||||
use std::convert::TryInto;
|
||||
use std::io::Cursor;
|
||||
use std::ops::Range;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
use termwiz::hyperlink::Hyperlink;
|
||||
use termwiz::surface::{Line, SequenceNo};
|
||||
@@ -401,7 +402,7 @@ macro_rules! pdu {
|
||||
/// The overall version of the codec.
|
||||
/// This must be bumped when backwards incompatible changes
|
||||
/// are made to the types and protocol.
|
||||
pub const CODEC_VERSION: usize = 11;
|
||||
pub const CODEC_VERSION: usize = 12;
|
||||
|
||||
// Defines the Pdu enum.
|
||||
// Each struct has an explicit identifying number.
|
||||
@@ -536,6 +537,8 @@ pub struct GetCodecVersion {}
|
||||
pub struct GetCodecVersionResponse {
|
||||
pub codec_vers: usize,
|
||||
pub version_string: String,
|
||||
pub executable_path: PathBuf,
|
||||
pub config_file_path: Option<PathBuf>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, PartialEq, Debug)]
|
||||
|
||||
@@ -946,7 +946,10 @@ impl Client {
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn verify_version_compat(&self, ui: &ConnectionUI) -> anyhow::Result<()> {
|
||||
pub async fn verify_version_compat(
|
||||
&self,
|
||||
ui: &ConnectionUI,
|
||||
) -> anyhow::Result<GetCodecVersionResponse> {
|
||||
match self.get_codec_version(GetCodecVersion {}).await {
|
||||
Ok(info) if info.codec_vers == CODEC_VERSION => {
|
||||
log::trace!(
|
||||
@@ -954,7 +957,7 @@ impl Client {
|
||||
info.version_string,
|
||||
info.codec_vers
|
||||
);
|
||||
Ok(())
|
||||
Ok(info)
|
||||
}
|
||||
Ok(info) => {
|
||||
let err = IncompatibleVersionError {
|
||||
|
||||
+13
-1
@@ -434,7 +434,19 @@ impl Publish {
|
||||
let executor = promise::spawn::ScopedExecutor::new();
|
||||
let command = cmd.clone();
|
||||
let res = block_on(executor.run(async move {
|
||||
client.verify_version_compat(&mut ui).await?;
|
||||
let vers = client.verify_version_compat(&mut ui).await?;
|
||||
|
||||
if vers.executable_path != std::env::current_exe().context("resolve executable path")? {
|
||||
anyhow::bail!(
|
||||
"Running GUI is a different executable from us, will start a new one");
|
||||
}
|
||||
if vers.config_file_path
|
||||
!= std::env::var_os("WEZTERM_CONFIG_FILE").map(Into::into)
|
||||
{
|
||||
anyhow::bail!(
|
||||
"Running GUI has different config from us, will start a new one"
|
||||
);
|
||||
}
|
||||
client
|
||||
.spawn_v2(codec::SpawnV2 {
|
||||
domain: config::keyassignment::SpawnTabDomain::DefaultDomain,
|
||||
|
||||
@@ -534,10 +534,18 @@ impl SessionHandler {
|
||||
}
|
||||
|
||||
Pdu::GetCodecVersion(_) => {
|
||||
send_response(Ok(Pdu::GetCodecVersionResponse(GetCodecVersionResponse {
|
||||
codec_vers: CODEC_VERSION,
|
||||
version_string: config::wezterm_version().to_owned(),
|
||||
})))
|
||||
match std::env::current_exe().context("resolving current_exe") {
|
||||
Err(err) => send_response(Err(err)),
|
||||
Ok(executable_path) => {
|
||||
send_response(Ok(Pdu::GetCodecVersionResponse(GetCodecVersionResponse {
|
||||
codec_vers: CODEC_VERSION,
|
||||
version_string: config::wezterm_version().to_owned(),
|
||||
executable_path,
|
||||
config_file_path: std::env::var_os("WEZTERM_CONFIG_FILE")
|
||||
.map(Into::into),
|
||||
})))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Pdu::GetTlsCreds(_) => {
|
||||
|
||||
Reference in new issue
Block a user