fix: resolve issue with file deletion during subscription removal

This commit is contained in:
Tunglies
2025-10-14 17:55:48 +08:00
parent f541464ff4
commit bb2059c76f
7 changed files with 52 additions and 88 deletions

View File

@@ -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(())
}
}