mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 00:35:38 +08:00
fix: upgrade mihomo core failed (#5646)
* fix: upgrade mihomo core failed * fix: upgrade core failed when run core by service * fix: app freeze when restart core on windows * deps: bump clash-verge-rev-ipc version lock --------- Co-authored-by: Tunglies <77394545+Tunglies@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use clash_verge_logger::AsyncLogger;
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
pub static CLASH_LOGGER: Lazy<Arc<AsyncLogger>> = Lazy::new(|| Arc::new(AsyncLogger::new()));
|
||||
// TODO: global logger to record verge log message
|
||||
|
||||
@@ -2,10 +2,8 @@ use super::{CoreManager, RunningMode};
|
||||
use crate::cmd::StringifyErr as _;
|
||||
use crate::config::{Config, IVerge};
|
||||
use crate::core::handle::Handle;
|
||||
use crate::core::{
|
||||
logger::CLASH_LOGGER,
|
||||
service::{SERVICE_MANAGER, ServiceStatus},
|
||||
};
|
||||
use crate::core::manager::CLASH_LOGGER;
|
||||
use crate::core::service::{SERVICE_MANAGER, ServiceStatus};
|
||||
use anyhow::Result;
|
||||
use clash_verge_logging::{Type, logging};
|
||||
use scopeguard::defer;
|
||||
@@ -44,11 +42,6 @@ impl CoreManager {
|
||||
pub async fn restart_core(&self) -> Result<()> {
|
||||
logging!(info, Type::Core, "Restarting core");
|
||||
self.stop_core().await?;
|
||||
|
||||
if SERVICE_MANAGER.lock().await.init().await.is_ok() {
|
||||
let _ = SERVICE_MANAGER.lock().await.refresh().await;
|
||||
}
|
||||
|
||||
self.start_core().await
|
||||
}
|
||||
|
||||
|
||||
@@ -4,11 +4,15 @@ mod state;
|
||||
|
||||
use anyhow::Result;
|
||||
use arc_swap::{ArcSwap, ArcSwapOption};
|
||||
use clash_verge_logger::AsyncLogger;
|
||||
use once_cell::sync::Lazy;
|
||||
use std::{fmt, sync::Arc, time::Instant};
|
||||
use tauri_plugin_shell::process::CommandChild;
|
||||
|
||||
use crate::singleton;
|
||||
|
||||
pub(crate) static CLASH_LOGGER: Lazy<Arc<AsyncLogger>> = Lazy::new(|| Arc::new(AsyncLogger::new()));
|
||||
|
||||
#[derive(Debug, serde::Serialize, PartialEq, Eq)]
|
||||
pub enum RunningMode {
|
||||
Service,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use super::{CoreManager, RunningMode};
|
||||
use crate::{
|
||||
AsyncHandler,
|
||||
config::Config,
|
||||
core::{handle, logger::CLASH_LOGGER, service},
|
||||
config::{Config, IClashTemp},
|
||||
core::{handle, manager::CLASH_LOGGER, service},
|
||||
logging,
|
||||
utils::{dirs, init::sidecar_writer},
|
||||
};
|
||||
@@ -39,6 +39,12 @@ impl CoreManager {
|
||||
dirs::path_to_str(&config_dir)?,
|
||||
"-f",
|
||||
dirs::path_to_str(&config_file)?,
|
||||
if cfg!(windows) {
|
||||
"-ext-ctl-pipe"
|
||||
} else {
|
||||
"-ext-ctl-unix"
|
||||
},
|
||||
&IClashTemp::guard_external_controller_ipc(),
|
||||
])
|
||||
.spawn()?;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
config::Config,
|
||||
config::{Config, IClashTemp},
|
||||
core::tray,
|
||||
utils::{dirs, init::service_writer_config},
|
||||
};
|
||||
@@ -405,6 +405,7 @@ pub(super) async fn start_with_existing_service(config_file: &PathBuf) -> Result
|
||||
core_config: CoreConfig {
|
||||
config_path: dirs::path_to_str(config_file)?.into(),
|
||||
core_path: dirs::path_to_str(&bin_path)?.into(),
|
||||
core_ipc_path: IClashTemp::guard_external_controller_ipc(),
|
||||
config_dir: dirs::path_to_str(&dirs::app_home_dir()?)?.into(),
|
||||
},
|
||||
log_config: service_writer_config().await?,
|
||||
|
||||
@@ -635,13 +635,13 @@ fn create_subcreate_proxy_menu_item(
|
||||
proxy_mode: &str,
|
||||
current_profile_selected: &[PrfSelected],
|
||||
proxy_group_order_map: Option<HashMap<String, usize>>,
|
||||
proxy_nodes_data: Result<Proxies>,
|
||||
proxy_nodes_data: Option<Proxies>,
|
||||
) -> Vec<Submenu<Wry>> {
|
||||
let proxy_submenus: Vec<Submenu<Wry>> = {
|
||||
let mut submenus: Vec<(String, usize, Submenu<Wry>)> = Vec::new();
|
||||
|
||||
// TODO: 应用启动时,内核还未启动完全,无法获取代理节点信息
|
||||
if let Ok(proxy_nodes_data) = proxy_nodes_data {
|
||||
if let Some(proxy_nodes_data) = proxy_nodes_data {
|
||||
for (group_name, group_data) in proxy_nodes_data.proxies.iter() {
|
||||
// Filter groups based on mode
|
||||
let should_show = match proxy_mode {
|
||||
@@ -827,7 +827,7 @@ async fn create_tray_menu(
|
||||
.unwrap_or_default()
|
||||
};
|
||||
|
||||
let proxy_nodes_data = handle::Handle::mihomo().await.get_proxies().await;
|
||||
let proxy_nodes_data = handle::Handle::mihomo().await.get_proxies().await.ok();
|
||||
|
||||
let runtime_proxy_groups_order = cmd::get_runtime_config()
|
||||
.await
|
||||
@@ -950,7 +950,7 @@ async fn create_tray_menu(
|
||||
current_proxy_mode,
|
||||
¤t_profile_selected,
|
||||
proxy_group_order_map,
|
||||
proxy_nodes_data.map_err(anyhow::Error::from),
|
||||
proxy_nodes_data,
|
||||
);
|
||||
|
||||
let (proxies_menu, inline_proxy_items) = create_proxy_menu_item(
|
||||
|
||||
Reference in New Issue
Block a user