windows: Fix auto update failure when launching from the cli (#34303)
Release Notes: - N/A --------- Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
This commit is contained in:
parent
658d56bd72
commit
32975c4208
13 changed files with 250 additions and 131 deletions
|
@ -201,16 +201,6 @@ pub fn main() {
|
|||
return;
|
||||
}
|
||||
|
||||
// Check if there is a pending installer
|
||||
// If there is, run the installer and exit
|
||||
// And we don't want to run the installer if we are not the first instance
|
||||
#[cfg(target_os = "windows")]
|
||||
let is_first_instance = crate::zed::windows_only_instance::is_first_instance();
|
||||
#[cfg(target_os = "windows")]
|
||||
if is_first_instance && auto_update::check_pending_installation() {
|
||||
return;
|
||||
}
|
||||
|
||||
if args.dump_all_actions {
|
||||
dump_all_gpui_actions();
|
||||
return;
|
||||
|
@ -283,30 +273,27 @@ pub fn main() {
|
|||
|
||||
let (open_listener, mut open_rx) = OpenListener::new();
|
||||
|
||||
let failed_single_instance_check =
|
||||
if *db::ZED_STATELESS || *release_channel::RELEASE_CHANNEL == ReleaseChannel::Dev {
|
||||
false
|
||||
} else {
|
||||
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
|
||||
{
|
||||
crate::zed::listen_for_cli_connections(open_listener.clone()).is_err()
|
||||
}
|
||||
let failed_single_instance_check = if *db::ZED_STATELESS
|
||||
|| *release_channel::RELEASE_CHANNEL == ReleaseChannel::Dev
|
||||
{
|
||||
false
|
||||
} else {
|
||||
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
|
||||
{
|
||||
crate::zed::listen_for_cli_connections(open_listener.clone()).is_err()
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
!crate::zed::windows_only_instance::handle_single_instance(
|
||||
open_listener.clone(),
|
||||
&args,
|
||||
is_first_instance,
|
||||
)
|
||||
}
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
!crate::zed::windows_only_instance::handle_single_instance(open_listener.clone(), &args)
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
use zed::mac_only_instance::*;
|
||||
ensure_only_instance() != IsOnlyInstance::Yes
|
||||
}
|
||||
};
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
use zed::mac_only_instance::*;
|
||||
ensure_only_instance() != IsOnlyInstance::Yes
|
||||
}
|
||||
};
|
||||
if failed_single_instance_check {
|
||||
println!("zed is already running");
|
||||
return;
|
||||
|
|
|
@ -25,7 +25,8 @@ use windows::{
|
|||
|
||||
use crate::{Args, OpenListener, RawOpenRequest};
|
||||
|
||||
pub fn is_first_instance() -> bool {
|
||||
#[inline]
|
||||
fn is_first_instance() -> bool {
|
||||
unsafe {
|
||||
CreateMutexW(
|
||||
None,
|
||||
|
@ -37,7 +38,8 @@ pub fn is_first_instance() -> bool {
|
|||
unsafe { GetLastError() != ERROR_ALREADY_EXISTS }
|
||||
}
|
||||
|
||||
pub fn handle_single_instance(opener: OpenListener, args: &Args, is_first_instance: bool) -> bool {
|
||||
pub fn handle_single_instance(opener: OpenListener, args: &Args) -> bool {
|
||||
let is_first_instance = is_first_instance();
|
||||
if is_first_instance {
|
||||
// We are the first instance, listen for messages sent from other instances
|
||||
std::thread::spawn(move || {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue