add basic integrity check on startup

This commit is contained in:
JMARyA 2024-09-19 11:42:59 +02:00
parent 1271387131
commit 416c1f06c1
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
2 changed files with 88 additions and 6 deletions

View file

@ -8,6 +8,7 @@ use rocket::{http::Method, launch};
mod config;
mod db;
mod flow;
mod integrity;
mod item;
mod json_store;
mod location;
@ -47,23 +48,20 @@ async fn rocket() -> _ {
.to_cors()
.expect("error creating CORS options");
let config = config::get_config();
let itemdb = db::ItemDB::new("./itemdb").await;
let mut locations: JSONStore<Location> = JSONStore::new("./locations");
let mut flows: JSONStore<FlowInfo> = JSONStore::new("./flows");
integrity::verify_integrity(&config, &flows, &locations, &itemdb).await;
for location in &mut *locations {
location.1.add(location.0).await;
}
let mut flows: JSONStore<FlowInfo> = JSONStore::new("./flows");
for flow in &mut *flows {
flow.1.add(flow.0).await;
}
let config = config::get_config();
// todo : log warnings on misconfiguration
rocket::build()
.mount(
"/",