This commit is contained in:
JMARyA 2024-10-07 21:35:50 +02:00
parent b4df75dcb6
commit 3eea2be3e8
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263

View file

@ -74,6 +74,30 @@ macro_rules! get_locations {
};
}
pub static FLOW_INFO: OnceCell<JSONStore<FlowInfo>> = OnceCell::const_new();
#[macro_export]
macro_rules! get_flows {
() => {
if let Some(client) = $crate::FLOW_INFO.get() {
client
} else {
let mut flows: $crate::json_store::JSONStore<$crate::flow::FlowInfo> =
$crate::JSONStore::new("./flows");
let flow_keys: Vec<_> = flows.keys().cloned().collect();
for flow_key in flow_keys {
let flow = flows.get_mut(&flow_key).unwrap();
flow.id = flow_key.clone();
}
$crate::FLOW_INFO.set(flows).unwrap();
$crate::FLOW_INFO.get().unwrap()
}
};
}
// ░░░░░░░░░░▀▀▀██████▄▄▄░░░░░░░░░░
// ░░░░░░░░░░░░░░░░░▀▀▀████▄░░░░░░░
// ░░░░░░░░░░▄███████▀░░░▀███▄░░░░░
@ -113,7 +137,7 @@ async fn rocket() -> _ {
let config = config::get_config();
let itemdb = get_itemdb!().clone();
let locations = get_locations!().clone();
let flows: JSONStore<FlowInfo> = JSONStore::new("./flows");
let flows = get_flows!().clone();
integrity::verify_integrity(&config, &flows, &locations, &itemdb).await;
rocket::build()