chore: Change service path

This commit is contained in:
MystiPanda 2023-12-13 10:59:07 +08:00
parent 16fa2c9f5e
commit eadd1042fb
2 changed files with 14 additions and 14 deletions

View File

@ -115,22 +115,12 @@ pub fn app_res_dir() -> Result<PathBuf> {
} }
pub fn clash_pid_path() -> Result<PathBuf> { pub fn clash_pid_path() -> Result<PathBuf> {
unsafe { Ok(app_home_dir()?.join("clash.pid"))
Ok(RESOURCE_DIR
.clone()
.ok_or(anyhow::anyhow!("failed to get the resource dir"))?
.join("clash.pid"))
}
} }
#[cfg(windows)] #[cfg(windows)]
pub fn service_path() -> Result<PathBuf> { pub fn service_path() -> Result<PathBuf> {
unsafe { Ok(app_home_dir()?.join("clash-verge-service.exe"))
let res_dir = RESOURCE_DIR
.clone()
.ok_or(anyhow::anyhow!("failed to get the resource dir"))?;
Ok(res_dir.join("clash-verge-service.exe"))
}
} }
#[cfg(windows)] #[cfg(windows)]

View File

@ -116,7 +116,10 @@ pub fn delete_log() -> Result<()> {
if file_name.ends_with(".log") { if file_name.ends_with(".log") {
let now = Local::now(); let now = Local::now();
let created_time = parse_time_str(&file_name[0..file_name.len() - 4])?; let created_time = parse_time_str(&file_name[0..file_name.len() - 4])?;
let file_time = Local.from_local_datetime(&created_time).single().ok_or(anyhow::anyhow!("invalid local datetime"))?; let file_time = Local
.from_local_datetime(&created_time)
.single()
.ok_or(anyhow::anyhow!("invalid local datetime"))?;
let duration = now.signed_duration_since(file_time); let duration = now.signed_duration_since(file_time);
if duration.num_days() > day { if duration.num_days() > day {
@ -197,7 +200,14 @@ pub fn init_resources(package_info: &PackageInfo) -> Result<()> {
} }
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
let file_list = ["Country.mmdb", "geoip.dat", "geosite.dat"]; let file_list = [
"Country.mmdb",
"geoip.dat",
"geosite.dat",
"clash-verge-service.exe",
"install-service.exe",
"uninstall-service.exe",
];
#[cfg(not(target_os = "windows"))] #[cfg(not(target_os = "windows"))]
let file_list = ["Country.mmdb", "geoip.dat", "geosite.dat"]; let file_list = ["Country.mmdb", "geoip.dat", "geosite.dat"];