mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-12-01 10:40:14 +08:00
fix(profile): recover interrupted subscription refreshes
Recover pending redo at startup, coordinate profile readers and writers, and publish Draft state only after persistence. Keep the Windows legacy path by default.
This commit is contained in:
@@ -246,10 +246,14 @@ async fn read_dns_settings(enabled: bool) -> Option<Mapping> {
|
||||
serde_yaml_ng::from_str(&yaml).ok()
|
||||
}
|
||||
|
||||
/// Returns the enhanced profile, its original keys, script logs, and DNS override decision.
|
||||
pub async fn enhance(
|
||||
profiles: &IProfiles,
|
||||
) -> Result<(Mapping, HashSet<String>, HashMap<String, ResultLog>, DnsOverrideState)> {
|
||||
pub(crate) struct ProfileRenderInputs {
|
||||
profile: RenderProfile,
|
||||
settings: RenderSettings,
|
||||
dns_config: Option<Mapping>,
|
||||
dns_override: DnsOverrideState,
|
||||
}
|
||||
|
||||
pub(crate) async fn collect_render_inputs(profiles: &IProfiles) -> Result<ProfileRenderInputs> {
|
||||
let profile_uid = profiles.current.as_deref().unwrap_or_default();
|
||||
let settings = get_config_values(profile_uid).await;
|
||||
let profile = collect_profile_items(profiles).await?;
|
||||
@@ -260,13 +264,24 @@ pub async fn enhance(
|
||||
settings.dns_override_confirmation,
|
||||
);
|
||||
let dns_config = read_dns_settings(dns_override.enabled).await;
|
||||
Ok(ProfileRenderInputs {
|
||||
profile,
|
||||
settings: settings.render,
|
||||
dns_config,
|
||||
dns_override,
|
||||
})
|
||||
}
|
||||
|
||||
/// Returns the enhanced profile, its original keys, script logs, and DNS override decision.
|
||||
pub(crate) async fn enhance(
|
||||
inputs: ProfileRenderInputs,
|
||||
) -> (Mapping, HashSet<String>, HashMap<String, ResultLog>, DnsOverrideState) {
|
||||
let RenderedConfig {
|
||||
config,
|
||||
exists_keys,
|
||||
logs,
|
||||
discarded_keys,
|
||||
} = render(profile, settings.render, dns_config).await;
|
||||
} = render(inputs.profile, inputs.settings, inputs.dns_config).await;
|
||||
notify_discarded_keys(discarded_keys);
|
||||
|
||||
Ok((config, exists_keys, logs, dns_override))
|
||||
(config, exists_keys, logs, inputs.dns_override)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user