refactor(profile): extract profile models and index rules

Move profile models and index rules into the crate, preserving serialization and returning a typed missing-profile error.
This commit is contained in:
Tunglies
2026-11-30 18:44:12 +08:00
parent b1281d78fe
commit e31c01894a
19 changed files with 1017 additions and 856 deletions
+2 -8
View File
@@ -2,7 +2,7 @@ use super::CmdResult;
use crate::{
cmd::StringifyErr as _,
cmd::validate::{ValidationNoticeTarget, handle_validation_notice},
config::{Config, IProfiles, PrfItem},
config::{Config, IProfiles, read_profile_item_file},
core::auto_backup::{self, AutoBackupTrigger},
core::{
CoreManager, handle,
@@ -58,13 +58,7 @@ pub async fn save_profile_file(
))
})?;
let original_content = if original_existed {
PrfItem {
file: Some(rel_path.clone()),
..Default::default()
}
.read_file()
.await
.stringify_err()?
read_profile_item_file(Some(rel_path.as_str())).await.stringify_err()?
} else {
String::new()
};