default unknown masters to slaveless

This commit is contained in:
LastExceed 2024-02-17 20:20:28 +01:00
parent 124bdab3a8
commit 12a99a28b1

View File

@ -1,4 +1,4 @@
use std::ops::Sub; use std::{collections::HashSet, ops::Sub};
use std::time::{Duration, Instant}; use std::time::{Duration, Instant};
use boolinator::Boolinator; use boolinator::Boolinator;
@ -133,13 +133,16 @@ impl State<Listener> {
pub async fn update_slaves(&mut self, master: &String, short_slaves: bool, long_slaves: bool, power: bool) -> Result<(), &'static str> { pub async fn update_slaves(&mut self, master: &String, short_slaves: bool, long_slaves: bool, power: bool) -> Result<(), &'static str> {
dark_grey_ln!("updating slaves..."); dark_grey_ln!("updating slaves...");
let fallback = HashSet::new();
let slaves_used_by_others = self let slaves_used_by_others = self
.bookings .bookings
.read() .read()
.await .await
.iter() .iter()
.filter(|(other, booking)| *other != master && booking.is_running()) .filter(|(other, booking)| *other != master && booking.is_running())
.flat_map(|(machine, _)| &SLAVES_BY_MASTER[machine]) //todo: error handing .flat_map(|(machine, _)| SLAVES_BY_MASTER.get(machine).unwrap_or(&fallback)) //machine being unknown already got logged when it got turned on, so we can ignore it here
.cloned() .cloned()
.collect(); .collect();