fix: optimize async handler usage in singleton checks and resource initialization #4576, #4590, #4609
This commit is contained in:
@@ -11,6 +11,8 @@
|
|||||||
- 修复2.4.1引入的订阅地址重定向报错问题
|
- 修复2.4.1引入的订阅地址重定向报错问题
|
||||||
- 修复 rpm/deb 包名称问题
|
- 修复 rpm/deb 包名称问题
|
||||||
- 修复托盘轻量模式状态检测异常
|
- 修复托盘轻量模式状态检测异常
|
||||||
|
- 修复通过 scheme 导入订阅奔溃
|
||||||
|
- 修复单例检测实效
|
||||||
|
|
||||||
### 👙 界面样式
|
### 👙 界面样式
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ mod app_init {
|
|||||||
|
|
||||||
/// Initialize singleton monitoring for other instances
|
/// Initialize singleton monitoring for other instances
|
||||||
pub fn init_singleton_check() {
|
pub fn init_singleton_check() {
|
||||||
AsyncHandler::spawn(move || async move {
|
AsyncHandler::spawn_blocking(move || async move {
|
||||||
logging!(info, Type::Setup, true, "开始检查单例实例...");
|
logging!(info, Type::Setup, true, "开始检查单例实例...");
|
||||||
match timeout(Duration::from_millis(500), server::check_singleton()).await {
|
match timeout(Duration::from_millis(500), server::check_singleton()).await {
|
||||||
Ok(result) => {
|
Ok(result) => {
|
||||||
@@ -94,7 +94,7 @@ mod app_init {
|
|||||||
app.deep_link().on_open_url(|event| {
|
app.deep_link().on_open_url(|event| {
|
||||||
let url = event.urls().first().map(|u| u.to_string());
|
let url = event.urls().first().map(|u| u.to_string());
|
||||||
if let Some(url) = url {
|
if let Some(url) = url {
|
||||||
tokio::task::spawn_local(async move {
|
AsyncHandler::spawn(|| async {
|
||||||
if let Err(e) = resolve::resolve_scheme(url).await {
|
if let Err(e) = resolve::resolve_scheme(url).await {
|
||||||
logging!(error, Type::Setup, true, "Failed to resolve scheme: {}", e);
|
logging!(error, Type::Setup, true, "Failed to resolve scheme: {}", e);
|
||||||
}
|
}
|
||||||
@@ -331,9 +331,8 @@ pub fn run() {
|
|||||||
|
|
||||||
logging!(info, Type::Setup, true, "执行主要设置操作...");
|
logging!(info, Type::Setup, true, "执行主要设置操作...");
|
||||||
|
|
||||||
logging!(info, Type::Setup, true, "异步执行应用设置...");
|
|
||||||
resolve::resolve_setup_sync(app_handle);
|
|
||||||
resolve::resolve_setup_async();
|
resolve::resolve_setup_async();
|
||||||
|
resolve::resolve_setup_sync(app_handle);
|
||||||
|
|
||||||
logging!(info, Type::Setup, true, "初始化完成,继续执行");
|
logging!(info, Type::Setup, true, "初始化完成,继续执行");
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -445,14 +445,6 @@ pub async fn init_resources() -> Result<()> {
|
|||||||
(Ok(src_modified), Ok(dest_modified)) => {
|
(Ok(src_modified), Ok(dest_modified)) => {
|
||||||
if src_modified > dest_modified {
|
if src_modified > dest_modified {
|
||||||
handle_copy(src_path.clone(), dest_path.clone(), file.to_string()).await;
|
handle_copy(src_path.clone(), dest_path.clone(), file.to_string()).await;
|
||||||
} else {
|
|
||||||
logging!(
|
|
||||||
debug,
|
|
||||||
Type::Setup,
|
|
||||||
true,
|
|
||||||
"skipping resource copy '{}'",
|
|
||||||
file
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ pub async fn check_singleton() -> Result<()> {
|
|||||||
pub fn embed_server() {
|
pub fn embed_server() {
|
||||||
let port = IVerge::get_singleton_port();
|
let port = IVerge::get_singleton_port();
|
||||||
|
|
||||||
AsyncHandler::spawn_blocking(move || async move {
|
AsyncHandler::spawn(move || async move {
|
||||||
let visible = warp::path!("commands" / "visible").and_then(|| async {
|
let visible = warp::path!("commands" / "visible").and_then(|| async {
|
||||||
Ok::<_, warp::Rejection>(warp::reply::with_status(
|
Ok::<_, warp::Rejection>(warp::reply::with_status(
|
||||||
"ok".to_string(),
|
"ok".to_string(),
|
||||||
|
|||||||
Reference in New Issue
Block a user