mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-09-13 02:54:26 +08:00
refactor: 修改为同步请求
This commit is contained in:
@@ -5,7 +5,7 @@ use crate::config::VideoConfig;
|
||||
use crate::error::Result;
|
||||
use crate::state::AppState;
|
||||
|
||||
use super::apply::apply_video_config;
|
||||
use super::apply::{apply_video_config, try_apply_lock, ConfigApplyOptions};
|
||||
use super::types::VideoConfigUpdate;
|
||||
|
||||
pub async fn get_video_config(State(state): State<Arc<AppState>>) -> Json<VideoConfig> {
|
||||
@@ -18,6 +18,7 @@ pub async fn update_video_config(
|
||||
) -> Result<Json<VideoConfig>> {
|
||||
req.validate()?;
|
||||
|
||||
let _apply_guard = try_apply_lock(&state.config_apply_locks.video, "video")?;
|
||||
let old_video_config = state.config.get().video.clone();
|
||||
|
||||
state
|
||||
@@ -29,10 +30,13 @@ pub async fn update_video_config(
|
||||
|
||||
let new_video_config = state.config.get().video.clone();
|
||||
|
||||
if let Err(e) = apply_video_config(&state, &old_video_config, &new_video_config).await {
|
||||
tracing::error!("Failed to apply video config: {}", e);
|
||||
// 根据用户选择,仅记录错误,不回滚
|
||||
}
|
||||
apply_video_config(
|
||||
&state,
|
||||
&old_video_config,
|
||||
&new_video_config,
|
||||
ConfigApplyOptions::forced(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(Json(new_video_config))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user