mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-04-18 08:21:34 +08:00
fix(profiles): add cleanup of orphaned files and adjust logging level
This commit is contained in:
parent
63cd4905f9
commit
9c6f5bc991
@ -89,6 +89,12 @@ impl Config {
|
|||||||
handle::Handle::notice_message(msg_type, msg_content);
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,7 @@ use clash_verge_logging::{Type, logging};
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_yaml_ng::Mapping;
|
use serde_yaml_ng::Mapping;
|
||||||
use smartstring::alias::String;
|
use smartstring::alias::String;
|
||||||
use std::{collections::HashSet, sync::Arc};
|
use std::collections::HashSet;
|
||||||
use tokio::fs;
|
use tokio::fs;
|
||||||
|
|
||||||
/// Define the `profiles.yaml` schema
|
/// Define the `profiles.yaml` schema
|
||||||
@ -126,15 +126,6 @@ impl IProfiles {
|
|||||||
bail!("failed to get the profile item \"uid:{}\"", uid_str);
|
bail!("failed to get the profile item \"uid:{}\"", uid_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_item_arc(&self, uid: &str) -> Option<Arc<PrfItem>> {
|
|
||||||
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
|
/// append new item
|
||||||
/// if the file_data is some
|
/// if the file_data is some
|
||||||
/// then should save the data to file
|
/// then should save the data to file
|
||||||
@ -420,7 +411,7 @@ impl IProfiles {
|
|||||||
match path.to_path_buf().remove_if_exists().await {
|
match path.to_path_buf().remove_if_exists().await {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
deleted_files.push(file_name.into());
|
deleted_files.push(file_name.into());
|
||||||
logging!(info, Type::Config, "已清理冗余文件: {file_name}");
|
logging!(debug, Type::Config, "已清理冗余文件: {file_name}");
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
failed_deletions.push(format!("{file_name}: {e}").into());
|
failed_deletions.push(format!("{file_name}: {e}").into());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user