mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-06-16 16:11:44 +08:00
refactor: 修改为同步请求
This commit is contained in:
@@ -5,7 +5,7 @@ use crate::config::HidConfig;
|
||||
use crate::error::Result;
|
||||
use crate::state::AppState;
|
||||
|
||||
use super::apply::apply_hid_config;
|
||||
use super::apply::{apply_hid_config, try_apply_lock, ConfigApplyOptions};
|
||||
use super::types::HidConfigUpdate;
|
||||
|
||||
pub async fn get_hid_config(State(state): State<Arc<AppState>>) -> Json<HidConfig> {
|
||||
@@ -18,6 +18,7 @@ pub async fn update_hid_config(
|
||||
) -> Result<Json<HidConfig>> {
|
||||
req.validate()?;
|
||||
|
||||
let _apply_guard = try_apply_lock(&state.config_apply_locks.otg, "otg")?;
|
||||
let old_hid_config = state.config.get().hid.clone();
|
||||
|
||||
state
|
||||
@@ -29,9 +30,13 @@ pub async fn update_hid_config(
|
||||
|
||||
let new_hid_config = state.config.get().hid.clone();
|
||||
|
||||
if let Err(e) = apply_hid_config(&state, &old_hid_config, &new_hid_config).await {
|
||||
tracing::error!("Failed to apply HID config: {}", e);
|
||||
}
|
||||
apply_hid_config(
|
||||
&state,
|
||||
&old_hid_config,
|
||||
&new_hid_config,
|
||||
ConfigApplyOptions::forced(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(Json(new_hid_config))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user