From b5952f320b7e18c33b7d28e80095ff109320e5c6 Mon Sep 17 00:00:00 2001 From: wonfen Date: Fri, 4 Apr 2025 13:18:17 +0800 Subject: [PATCH] fix: #3244, remove test directory, simplify resource initialization --- src-tauri/src/core/core.rs | 8 ++++---- src-tauri/src/utils/init.rs | 8 -------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src-tauri/src/core/core.rs b/src-tauri/src/core/core.rs index 5d0213d4..2ab0982b 100644 --- a/src-tauri/src/core/core.rs +++ b/src-tauri/src/core/core.rs @@ -247,15 +247,15 @@ impl CoreManager { logging!(info, Type::Config, true, "使用内核: {}", clash_core); let app_handle = handle::Handle::global().app_handle().unwrap(); - let test_dir = dirs::app_home_dir()?.join("test"); - let test_dir = dirs::path_to_str(&test_dir)?; - logging!(info, Type::Config, true, "测试目录: {}", test_dir); + let app_dir = dirs::app_home_dir()?; + let app_dir_str = dirs::path_to_str(&app_dir)?; + logging!(info, Type::Config, true, "验证目录: {}", app_dir_str); // 使用子进程运行clash验证配置 let output = app_handle .shell() .sidecar(clash_core)? - .args(["-t", "-d", test_dir, "-f", config_path]) + .args(["-t", "-d", app_dir_str, "-f", config_path]) .output() .await?; diff --git a/src-tauri/src/utils/init.rs b/src-tauri/src/utils/init.rs index 95806f9e..1e97f07b 100644 --- a/src-tauri/src/utils/init.rs +++ b/src-tauri/src/utils/init.rs @@ -295,15 +295,11 @@ pub fn init_config() -> Result<()> { /// after tauri setup pub fn init_resources() -> Result<()> { let app_dir = dirs::app_home_dir()?; - let test_dir = app_dir.join("test"); let res_dir = dirs::app_resources_dir()?; if !app_dir.exists() { let _ = fs::create_dir_all(&app_dir); } - if !test_dir.exists() { - let _ = fs::create_dir_all(&test_dir); - } if !res_dir.exists() { let _ = fs::create_dir_all(&res_dir); } @@ -315,7 +311,6 @@ pub fn init_resources() -> Result<()> { for file in file_list.iter() { let src_path = res_dir.join(file); let dest_path = app_dir.join(file); - let test_dest_path = test_dir.join(file); log::debug!(target: "app", "src_path: {src_path:?}, dest_path: {dest_path:?}"); let handle_copy = |dest: &PathBuf| { @@ -327,9 +322,6 @@ pub fn init_resources() -> Result<()> { }; }; - if src_path.exists() && !test_dest_path.exists() { - handle_copy(&test_dest_path); - } if src_path.exists() && !dest_path.exists() { handle_copy(&dest_path); continue;