Correction on cache system
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
env::var,
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
@@ -153,8 +154,13 @@ impl ActionInstance {
|
||||
|
||||
for (arg_name, state_value) in soap_data.iter() {
|
||||
if let Some(arg_inst) = self.argument(arg_name) {
|
||||
if arg_inst.get_model().is_in() {
|
||||
action_data.insert(arg_name.clone(), state_value.to_reflect());
|
||||
if arg_inst.is_in() {
|
||||
if let Some(var_inst) = arg_inst.get_variable_instance() {
|
||||
action_data
|
||||
.insert(arg_name.clone(), var_inst.parse_value(state_value.clone()));
|
||||
} else {
|
||||
action_data.insert(arg_name.clone(), state_value.to_reflect());
|
||||
}
|
||||
updated.insert(arg_name.clone());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,16 +56,16 @@ impl Action {
|
||||
/// Il peut être remplacé via [`set_handler`](Self::set_handler).
|
||||
fn default_handler() -> ActionHandler {
|
||||
action_handler!(|data| {
|
||||
info!("🎬 Action called with default handler");
|
||||
|
||||
let mut s = String::new();
|
||||
// Logger les arguments
|
||||
for (key, value) in data.iter() {
|
||||
trace!(
|
||||
" {} = {}",
|
||||
s.push_str(&format![
|
||||
"- {} = {}\n",
|
||||
key,
|
||||
crate::actions::reflect_to_string(value.as_ref())
|
||||
);
|
||||
]);
|
||||
}
|
||||
info!("🎬 Action called with default handler\n\n{}", s);
|
||||
|
||||
// Retourner les données telles quelles
|
||||
Ok(data)
|
||||
|
||||
@@ -247,6 +247,10 @@ impl ArgumentInstance {
|
||||
pub fn get_variable_instance(&self) -> Option<Arc<StateVarInstance>> {
|
||||
self.variable_instance.read().unwrap().clone()
|
||||
}
|
||||
|
||||
pub fn is_in(&self) -> bool {
|
||||
self.model.is_in()
|
||||
}
|
||||
}
|
||||
|
||||
impl UpnpInstance for ActionInstanceSet {
|
||||
|
||||
@@ -195,6 +195,16 @@ macro_rules! get {
|
||||
($data:expr, $key:expr, $type:ty) => {
|
||||
$crate::actions::get_value::<$type>($data, $key)?
|
||||
};
|
||||
($data:expr, $key:expr, $type:ty, $($msg:tt)+) => {{
|
||||
match $crate::actions::get_value::<$type>($data, $key) {
|
||||
Ok(value) => value,
|
||||
Err(_) => {
|
||||
let message = format!($($msg)+);
|
||||
tracing::error!("{}", message);
|
||||
return Err($crate::actions::ActionError::ArgumentError(message));
|
||||
}
|
||||
}
|
||||
}};
|
||||
}
|
||||
|
||||
/// Macro pour insérer facilement une valeur dans ActionData.
|
||||
|
||||
Reference in New Issue
Block a user