fix(service): don't ask to repair the service when the proxy clear fails

This commit is contained in:
wonfen
2026-09-29 10:09:21 +08:00
parent 0c7e0c8535
commit c4f9d65e07
+21 -1
View File
@@ -833,7 +833,10 @@ fn record_service_start_refusal<E: RunStateEnv>(
store: &RunStateStore<E>,
refusal: ServiceStartRefusal,
) -> anyhow::Error {
if store.state().mode == crate::core::manager::RunningMode::NotRunning {
// A proxy clear failure is about the system network settings; repairing the service cannot fix it.
if store.state().mode == crate::core::manager::RunningMode::NotRunning
&& refusal.code != ServiceErrorCode::ProxyClearFailed as u16
{
store.observe(ServiceHealth::Unavailable(refusal.to_string()));
}
refusal.into()
@@ -2312,6 +2315,23 @@ mod tests {
Ok(())
}
#[test]
fn proxy_clear_refusal_does_not_ask_for_service_repair() {
let store = fake_store();
store.observe(ServiceHealth::Ready);
let _ = super::record_service_start_refusal(
&store,
super::ServiceStartRefusal {
code: clash_verge_service_ipc::ServiceErrorCode::ProxyClearFailed as u16,
core_path: "/development/service-core/verge-mihomo".into(),
message: "SystemConfiguration operation failed: lock preferences (status 3002)".into(),
},
);
assert!(store.state().service_usable());
assert!(!store.state().service_needs_attention());
}
#[test]
fn cached_readiness_is_false_while_a_service_operation_is_running() {
let store = fake_store();