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:
Tunglies
2026-11-30 18:44:12 +08:00
parent 0415133c88
commit 2c8b532f68
22 changed files with 1465 additions and 172 deletions
+22 -7
View File
@@ -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)
}