mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-10-15 05:40:47 +08:00
fix(service): don't ask to repair the service when the proxy clear fails
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user