mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 00:35:38 +08:00
fix: resolve issue with file deletion during subscription removal
This commit is contained in:
@@ -52,6 +52,7 @@
|
|||||||
- 修复 Linux WebKit 网络进程的崩溃
|
- 修复 Linux WebKit 网络进程的崩溃
|
||||||
- 修复无法导入订阅
|
- 修复无法导入订阅
|
||||||
- 修复实际导入成功但显示导入失败的问题
|
- 修复实际导入成功但显示导入失败的问题
|
||||||
|
- 修复删除订阅时未能实际删除相关文件
|
||||||
- 修复 macOS 连接界面显示异常
|
- 修复 macOS 连接界面显示异常
|
||||||
|
|
||||||
## v2.4.2
|
## v2.4.2
|
||||||
|
|||||||
1
src-tauri/Cargo.lock
generated
1
src-tauri/Cargo.lock
generated
@@ -1104,6 +1104,7 @@ version = "2.4.3"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"aes-gcm",
|
"aes-gcm",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
|
"async-trait",
|
||||||
"backoff",
|
"backoff",
|
||||||
"base64 0.22.1",
|
"base64 0.22.1",
|
||||||
"boa_engine",
|
"boa_engine",
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ clash_verge_logger = { version = "0.1.0", git = "https://github.com/clash-verge-
|
|||||||
clash_verge_service_ipc = { version = "2.0.16", features = [
|
clash_verge_service_ipc = { version = "2.0.16", features = [
|
||||||
"client",
|
"client",
|
||||||
], git = "https://github.com/clash-verge-rev/clash-verge-service-ipc" }
|
], git = "https://github.com/clash-verge-rev/clash-verge-service-ipc" }
|
||||||
|
async-trait = "0.1.89"
|
||||||
# clash_verge_service_ipc = { version = "2.0.16", features = [
|
# clash_verge_service_ipc = { version = "2.0.16", features = [
|
||||||
# "client",
|
# "client",
|
||||||
# ], path = "../../clash-verge-service-ipc" }
|
# ], path = "../../clash-verge-service-ipc" }
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
use super::CmdResult;
|
use super::CmdResult;
|
||||||
use crate::{
|
use crate::{
|
||||||
|
cmd::StringifyErr,
|
||||||
config::{
|
config::{
|
||||||
Config, IProfiles, PrfItem, PrfOption,
|
Config, IProfiles, PrfItem, PrfOption,
|
||||||
profiles::{
|
profiles::{
|
||||||
@@ -191,8 +192,10 @@ pub async fn update_profile(index: String, option: Option<PrfOption>) -> CmdResu
|
|||||||
/// 删除配置文件
|
/// 删除配置文件
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn delete_profile(index: String) -> CmdResult {
|
pub async fn delete_profile(index: String) -> CmdResult {
|
||||||
|
println!("delete_profile: {}", index);
|
||||||
// 使用Send-safe helper函数
|
// 使用Send-safe helper函数
|
||||||
let should_update = wrap_err!(profiles_delete_item_safe(index.clone()).await)?;
|
let should_update = wrap_err!(profiles_delete_item_safe(index.clone()).await)?;
|
||||||
|
profiles_save_file_safe().await.stringify_err()?;
|
||||||
|
|
||||||
if should_update {
|
if should_update {
|
||||||
match CoreManager::global().update_config().await {
|
match CoreManager::global().update_config().await {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use super::{PrfOption, prfitem::PrfItem};
|
use super::{PrfOption, prfitem::PrfItem};
|
||||||
use crate::{
|
use crate::utils::{
|
||||||
logging_error,
|
dirs::{self, PathBufExec},
|
||||||
utils::{dirs, help, logging::Type},
|
help,
|
||||||
};
|
};
|
||||||
use anyhow::{Context, Result, bail};
|
use anyhow::{Context, Result, bail};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
@@ -290,20 +290,10 @@ impl IProfiles {
|
|||||||
if let Some(index) = index
|
if let Some(index) = index
|
||||||
&& let Some(file) = items.remove(index).file
|
&& let Some(file) = items.remove(index).file
|
||||||
{
|
{
|
||||||
let _ = dirs::app_profiles_dir().map(async move |path| {
|
let _ = dirs::app_profiles_dir()?
|
||||||
let path = path.join(file);
|
.join(file)
|
||||||
if path.exists() {
|
.remove_if_exists()
|
||||||
let result = fs::remove_file(path.clone()).await;
|
.await;
|
||||||
if let Err(err) = result {
|
|
||||||
logging_error!(
|
|
||||||
Type::Config,
|
|
||||||
"[配置文件删除] 删除文件 {} 失败: {}",
|
|
||||||
path.display(),
|
|
||||||
err
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
// get the merge index
|
// get the merge index
|
||||||
for (i, _) in items.iter().enumerate() {
|
for (i, _) in items.iter().enumerate() {
|
||||||
@@ -315,20 +305,10 @@ impl IProfiles {
|
|||||||
if let Some(index) = merge_index
|
if let Some(index) = merge_index
|
||||||
&& let Some(file) = items.remove(index).file
|
&& let Some(file) = items.remove(index).file
|
||||||
{
|
{
|
||||||
let _ = dirs::app_profiles_dir().map(async move |path| {
|
let _ = dirs::app_profiles_dir()?
|
||||||
let path = path.join(file);
|
.join(file)
|
||||||
if path.exists() {
|
.remove_if_exists()
|
||||||
let result = fs::remove_file(path.clone()).await;
|
.await;
|
||||||
if let Err(err) = result {
|
|
||||||
logging_error!(
|
|
||||||
Type::Config,
|
|
||||||
"[配置文件删除] 删除文件 {} 失败: {}",
|
|
||||||
path.display(),
|
|
||||||
err
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
// get the script index
|
// get the script index
|
||||||
for (i, _) in items.iter().enumerate() {
|
for (i, _) in items.iter().enumerate() {
|
||||||
@@ -340,20 +320,10 @@ impl IProfiles {
|
|||||||
if let Some(index) = script_index
|
if let Some(index) = script_index
|
||||||
&& let Some(file) = items.remove(index).file
|
&& let Some(file) = items.remove(index).file
|
||||||
{
|
{
|
||||||
let _ = dirs::app_profiles_dir().map(async move |path| {
|
let _ = dirs::app_profiles_dir()?
|
||||||
let path = path.join(file);
|
.join(file)
|
||||||
if path.exists() {
|
.remove_if_exists()
|
||||||
let result = fs::remove_file(path.clone()).await;
|
.await;
|
||||||
if let Err(err) = result {
|
|
||||||
logging_error!(
|
|
||||||
Type::Config,
|
|
||||||
"[配置文件删除] 删除文件 {} 失败: {}",
|
|
||||||
path.display(),
|
|
||||||
err
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
// get the rules index
|
// get the rules index
|
||||||
for (i, _) in items.iter().enumerate() {
|
for (i, _) in items.iter().enumerate() {
|
||||||
@@ -365,20 +335,10 @@ impl IProfiles {
|
|||||||
if let Some(index) = rules_index
|
if let Some(index) = rules_index
|
||||||
&& let Some(file) = items.remove(index).file
|
&& let Some(file) = items.remove(index).file
|
||||||
{
|
{
|
||||||
let _ = dirs::app_profiles_dir().map(async move |path| {
|
let _ = dirs::app_profiles_dir()?
|
||||||
let path = path.join(file);
|
.join(file)
|
||||||
if path.exists() {
|
.remove_if_exists()
|
||||||
let result = fs::remove_file(path.clone()).await;
|
.await;
|
||||||
if let Err(err) = result {
|
|
||||||
logging_error!(
|
|
||||||
Type::Config,
|
|
||||||
"[配置文件删除] 删除文件 {} 失败: {}",
|
|
||||||
path.display(),
|
|
||||||
err
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
// get the proxies index
|
// get the proxies index
|
||||||
for (i, _) in items.iter().enumerate() {
|
for (i, _) in items.iter().enumerate() {
|
||||||
@@ -390,20 +350,10 @@ impl IProfiles {
|
|||||||
if let Some(index) = proxies_index
|
if let Some(index) = proxies_index
|
||||||
&& let Some(file) = items.remove(index).file
|
&& let Some(file) = items.remove(index).file
|
||||||
{
|
{
|
||||||
let _ = dirs::app_profiles_dir().map(async move |path| {
|
let _ = dirs::app_profiles_dir()?
|
||||||
let path = path.join(file);
|
.join(file)
|
||||||
if path.exists() {
|
.remove_if_exists()
|
||||||
let result = fs::remove_file(path.clone()).await;
|
.await;
|
||||||
if let Err(err) = result {
|
|
||||||
logging_error!(
|
|
||||||
Type::Config,
|
|
||||||
"[配置文件删除] 删除文件 {} 失败: {}",
|
|
||||||
path.display(),
|
|
||||||
err
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
// get the groups index
|
// get the groups index
|
||||||
for (i, _) in items.iter().enumerate() {
|
for (i, _) in items.iter().enumerate() {
|
||||||
@@ -415,20 +365,10 @@ impl IProfiles {
|
|||||||
if let Some(index) = groups_index
|
if let Some(index) = groups_index
|
||||||
&& let Some(file) = items.remove(index).file
|
&& let Some(file) = items.remove(index).file
|
||||||
{
|
{
|
||||||
let _ = dirs::app_profiles_dir().map(async move |path| {
|
let _ = dirs::app_profiles_dir()?
|
||||||
let path = path.join(file);
|
.join(file)
|
||||||
if path.exists() {
|
.remove_if_exists()
|
||||||
let result = fs::remove_file(path.clone()).await;
|
.await;
|
||||||
if let Err(err) = result {
|
|
||||||
logging_error!(
|
|
||||||
Type::Config,
|
|
||||||
"[配置文件删除] 删除文件 {} 失败: {}",
|
|
||||||
path.display(),
|
|
||||||
err
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
// delete the original uid
|
// delete the original uid
|
||||||
if current == uid {
|
if current == uid {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
use crate::core::handle;
|
use crate::{core::handle, logging, utils::logging::Type};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
use async_trait::async_trait;
|
||||||
use once_cell::sync::OnceCell;
|
use once_cell::sync::OnceCell;
|
||||||
use std::{fs, path::PathBuf};
|
use std::{fs, path::PathBuf};
|
||||||
use tauri::Manager;
|
use tauri::Manager;
|
||||||
@@ -232,3 +233,18 @@ pub fn ipc_path() -> Result<PathBuf> {
|
|||||||
pub fn ipc_path() -> Result<PathBuf> {
|
pub fn ipc_path() -> Result<PathBuf> {
|
||||||
Ok(PathBuf::from(r"\\.\pipe\verge-mihomo"))
|
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(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ pub enum Type {
|
|||||||
Timer,
|
Timer,
|
||||||
Frontend,
|
Frontend,
|
||||||
Backup,
|
Backup,
|
||||||
|
File,
|
||||||
Lightweight,
|
Lightweight,
|
||||||
Network,
|
Network,
|
||||||
ProxyMode,
|
ProxyMode,
|
||||||
@@ -47,6 +48,7 @@ impl fmt::Display for Type {
|
|||||||
Type::Timer => write!(f, "[Timer]"),
|
Type::Timer => write!(f, "[Timer]"),
|
||||||
Type::Frontend => write!(f, "[Frontend]"),
|
Type::Frontend => write!(f, "[Frontend]"),
|
||||||
Type::Backup => write!(f, "[Backup]"),
|
Type::Backup => write!(f, "[Backup]"),
|
||||||
|
Type::File => write!(f, "[File]"),
|
||||||
Type::Lightweight => write!(f, "[Lightweight]"),
|
Type::Lightweight => write!(f, "[Lightweight]"),
|
||||||
Type::Network => write!(f, "[Network]"),
|
Type::Network => write!(f, "[Network]"),
|
||||||
Type::ProxyMode => write!(f, "[ProxMode]"),
|
Type::ProxyMode => write!(f, "[ProxMode]"),
|
||||||
|
|||||||
Reference in New Issue
Block a user