feat: add function to retrieve profile name by UID and improve error logging for profile updates

This commit is contained in:
Tunglies
2025-11-02 20:07:47 +08:00
parent 85244a8f86
commit fb5bf72fb9
3 changed files with 23 additions and 8 deletions

View File

@@ -435,8 +435,8 @@ impl IProfiles {
}
/// 判断profile是否是current指向的
pub fn is_current_profile_index(&self, index: String) -> bool {
self.current == Some(index)
pub fn is_current_profile_index(&self, index: &String) -> bool {
self.current.as_ref() == Some(index)
}
/// 获取所有的profiles(uid名称)
@@ -455,6 +455,18 @@ impl IProfiles {
})
}
/// 通过 uid 获取名称
pub fn get_name_by_uid(&self, uid: &String) -> Option<String> {
if let Some(items) = &self.items {
for item in items {
if item.uid.as_ref() == Some(uid) {
return item.name.clone();
}
}
}
None
}
/// 以 app 中的 profile 列表为准,删除不再需要的文件
pub async fn cleanup_orphaned_files(&self) -> Result<CleanupResult> {
let profiles_dir = dirs::app_profiles_dir()?;