mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-12-01 02:20:07 +08:00
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:
@@ -1,5 +1,8 @@
|
||||
use crate::{
|
||||
config::{Config, IClashTemp, IProfiles, IVerge},
|
||||
config::{
|
||||
Config, IClashTemp, IProfiles, IVerge,
|
||||
profiles::{raise_short_update_intervals, save_profiles},
|
||||
},
|
||||
constants,
|
||||
core::handle,
|
||||
logging,
|
||||
@@ -266,9 +269,9 @@ pub async fn migrate_short_update_intervals() -> Result<()> {
|
||||
if profiles.items.is_none() {
|
||||
anyhow::bail!("profiles.yaml was not loaded; refusing to record the migration as done");
|
||||
}
|
||||
let raised = profiles.raise_short_update_intervals(min);
|
||||
let raised = raise_short_update_intervals(&mut profiles, min);
|
||||
if raised > 0 {
|
||||
profiles.save_file().await?;
|
||||
save_profiles(&profiles).await?;
|
||||
}
|
||||
Ok((profiles, raised))
|
||||
})
|
||||
|
||||
@@ -5,7 +5,7 @@ use tauri::Url;
|
||||
use tristr::alias::String;
|
||||
|
||||
use crate::{
|
||||
config::{Config, PrfItem, profiles},
|
||||
config::{Config, PrfItem, fetch_remote_profile, profiles},
|
||||
core::{CoreManager, handle, timer::Timer},
|
||||
utils::help,
|
||||
};
|
||||
@@ -113,7 +113,7 @@ async fn import_subscription(url: &str, name: Option<&String>) {
|
||||
}
|
||||
|
||||
async fn fetch_profile_item(url: &str, name: Option<&String>) -> Option<PrfItem> {
|
||||
match PrfItem::from_url(url, name, None, None).await {
|
||||
match fetch_remote_profile(url, name, None, None).await {
|
||||
Ok(item) => Some(item),
|
||||
Err(e) => {
|
||||
logging!(error, Type::Config, "failed to parse profile from url: {:?}", e);
|
||||
|
||||
Reference in New Issue
Block a user