Skip to content

Commit 3c982ba

Browse files
committed
Crash if sites root node doesn't have an HP3 key
The root node must have an HP3 key, otherwise this HP is not visible to parent instances.
1 parent 0ada4fd commit 3c982ba

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/sites.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,12 +398,24 @@ pub(crate) async fn sites_task(
398398
shvclient::ClientEvent::Connected(shv_api_version) => {
399399
log::info!("Getting sites info");
400400

401-
let sites = RpcCall::new("sites", "getSites")
401+
let sites: Result<shvproto::Map, _> = RpcCall::new("sites", "getSites")
402402
.exec(&client_cmd_tx)
403403
.await;
404404

405405
let (sites_info, sub_hps) = match sites {
406406
Ok(sites) => {
407+
if sites
408+
.get("_meta")
409+
.map(RpcValue::as_map)
410+
.and_then(|map| map.get("HP3"))
411+
.map(RpcValue::as_map)
412+
.and_then(|map| map.get("type"))
413+
.map(RpcValue::as_str)
414+
.is_none_or(|type_str| type_str != "HP3")
415+
{
416+
eprintln!("This site's _meta does NOT include an HP3 node. Refusing to continue. Add an HP3 node to the site's _meta, otherwise this HP instance will not be visible to parent HPs.");
417+
std::process::abort();
418+
}
407419
let sub_hps = collect_sub_hps(&[], &sites);
408420
let mut sites_info = collect_sites(&[], &sites);
409421
for (path, site_info) in &mut sites_info {

0 commit comments

Comments
 (0)