mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 08:45:41 +08:00
fix: resolve issue with file deletion during subscription removal
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use crate::core::handle;
|
||||
use crate::{core::handle, logging, utils::logging::Type};
|
||||
use anyhow::Result;
|
||||
use async_trait::async_trait;
|
||||
use once_cell::sync::OnceCell;
|
||||
use std::{fs, path::PathBuf};
|
||||
use tauri::Manager;
|
||||
@@ -232,3 +233,18 @@ pub fn ipc_path() -> Result<PathBuf> {
|
||||
pub fn ipc_path() -> Result<PathBuf> {
|
||||
Ok(PathBuf::from(r"\\.\pipe\verge-mihomo"))
|
||||
}
|
||||
#[async_trait]
|
||||
pub trait PathBufExec {
|
||||
async fn remove_if_exists(&self) -> Result<()>;
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl PathBufExec for PathBuf {
|
||||
async fn remove_if_exists(&self) -> Result<()> {
|
||||
if self.exists() {
|
||||
tokio::fs::remove_file(self).await?;
|
||||
logging!(info, Type::File, "Removed file: {:?}", self);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user