wait for control job to be done

This commit is contained in:
Jonathan Baecker 2024-10-15 11:47:45 +02:00
parent 7827851a40
commit 64e0d7af9f
3 changed files with 15 additions and 4 deletions

View File

@ -869,10 +869,22 @@ pub async fn control_playout(
) -> Result<impl Responder, ServiceError> { ) -> Result<impl Responder, ServiceError> {
let manager = controllers.lock().unwrap().get(*id).unwrap(); let manager = controllers.lock().unwrap().get(*id).unwrap();
match control_state(&pool, manager, &control.control).await { if manager.is_processing.load(Ordering::SeqCst) {
return Err(ServiceError::Conflict(
"A command is already being processed, please wait".to_string(),
));
}
manager.is_processing.store(true, Ordering::SeqCst);
let resp = match control_state(&pool, &manager, &control.control).await {
Ok(res) => Ok(web::Json(res)), Ok(res) => Ok(web::Json(res)),
Err(e) => Err(e), Err(e) => Err(e),
} };
manager.is_processing.store(false, Ordering::SeqCst);
resp
} }
/// **Get current Clip** /// **Get current Clip**

View File

@ -132,7 +132,7 @@ pub async fn send_message(
pub async fn control_state( pub async fn control_state(
conn: &Pool<Sqlite>, conn: &Pool<Sqlite>,
manager: ChannelManager, manager: &ChannelManager,
command: &str, command: &str,
) -> Result<Map<String, Value>, ServiceError> { ) -> Result<Map<String, Value>, ServiceError> {
let config = manager.config.lock().unwrap().clone(); let config = manager.config.lock().unwrap().clone();

View File

@ -2,7 +2,6 @@ import { cloneDeep } from 'lodash-es'
import { defineStore } from 'pinia' import { defineStore } from 'pinia'
import type { AdvancedConfig } from '~/types/advanced_config' import type { AdvancedConfig } from '~/types/advanced_config'
export const useConfig = defineStore('config', { export const useConfig = defineStore('config', {
state: () => ({ state: () => ({
i: 0, i: 0,