mirror of
https://github.com/clash-verge-rev/clash-verge-rev
synced 2025-05-04 20:37:32 +08:00
fix: #3244, remove test directory, simplify resource initialization
This commit is contained in:
parent
98be9621a6
commit
b5952f320b
@ -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?;
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user