fix: 修复扩展服务开启和自启动状态错误

This commit is contained in:
mofeng-git
2026-07-17 10:46:34 +08:00
parent 57d1597264
commit d35021ee5d
12 changed files with 430 additions and 136 deletions

View File

@@ -30,7 +30,7 @@ async fn persist_and_apply(
state,
&old_config,
&stored_config,
ConfigApplyOptions::forced(),
ConfigApplyOptions::preserving_service_state(),
)
.await?;
Ok(stored_config)
@@ -76,10 +76,17 @@ pub async fn start_rtsp_service(
State(state): State<Arc<AppState>>,
) -> Result<Json<RtspStatusResponse>> {
let _apply_guard = try_apply_lock(&state.config_apply_locks.rtsp, "rtsp")?;
let current_config = state.config.get().rtsp.clone();
let mut start_config = current_config.clone();
let stored_config = state.config.get().rtsp.clone();
let runtime_config = state.runtime_third_party_config().await.rtsp;
let mut start_config = stored_config.clone();
start_config.enabled = true;
let stored_config = persist_and_apply(&state, current_config, start_config).await?;
apply_rtsp_config(
&state,
&runtime_config,
&start_config,
ConfigApplyOptions::runtime_only(),
)
.await?;
let status = current_status(&state).await;
Ok(Json(RtspStatusResponse::new(&stored_config, status)))
@@ -89,11 +96,17 @@ pub async fn stop_rtsp_service(
State(state): State<Arc<AppState>>,
) -> Result<Json<RtspStatusResponse>> {
let _apply_guard = try_apply_lock(&state.config_apply_locks.rtsp, "rtsp")?;
let current_config = state.config.get().rtsp.clone();
let mut stop_config = current_config.clone();
let stored_config = state.config.get().rtsp.clone();
let runtime_config = state.runtime_third_party_config().await.rtsp;
let mut stop_config = stored_config.clone();
stop_config.enabled = false;
let stored_config = persist_and_apply(&state, current_config, stop_config).await?;
apply_rtsp_config(
&state,
&runtime_config,
&stop_config,
ConfigApplyOptions::runtime_only(),
)
.await?;
let status = current_status(&state).await;
Ok(Json(RtspStatusResponse::new(&stored_config, status)))