diff --git a/src-tauri/src/config/config.rs b/src-tauri/src/config/config.rs index 99f270e2c..ca91f2dd0 100644 --- a/src-tauri/src/config/config.rs +++ b/src-tauri/src/config/config.rs @@ -89,6 +89,12 @@ impl Config { handle::Handle::notice_message(msg_type, msg_content); } + { + let profiles = Self::profiles().await.data_arc(); + // Logging error internally + let _ = profiles.cleanup_orphaned_files().await; + } + Ok(()) } diff --git a/src-tauri/src/config/profiles.rs b/src-tauri/src/config/profiles.rs index cb386689f..f269c1be3 100644 --- a/src-tauri/src/config/profiles.rs +++ b/src-tauri/src/config/profiles.rs @@ -8,7 +8,7 @@ use clash_verge_logging::{Type, logging}; use serde::{Deserialize, Serialize}; use serde_yaml_ng::Mapping; use smartstring::alias::String; -use std::{collections::HashSet, sync::Arc}; +use std::collections::HashSet; use tokio::fs; /// Define the `profiles.yaml` schema @@ -126,15 +126,6 @@ impl IProfiles { bail!("failed to get the profile item \"uid:{}\"", uid_str); } - pub fn get_item_arc(&self, uid: &str) -> Option> { - self.items.as_ref().and_then(|items| { - items - .iter() - .find(|it| it.uid.as_deref() == Some(uid)) - .map(|it| Arc::new(it.clone())) - }) - } - /// append new item /// if the file_data is some /// then should save the data to file @@ -420,7 +411,7 @@ impl IProfiles { match path.to_path_buf().remove_if_exists().await { Ok(_) => { deleted_files.push(file_name.into()); - logging!(info, Type::Config, "已清理冗余文件: {file_name}"); + logging!(debug, Type::Config, "已清理冗余文件: {file_name}"); } Err(e) => { failed_deletions.push(format!("{file_name}: {e}").into());