Load plan from local_store if http fetch fails

This commit is contained in:
Jeremy Wall 2023-01-07 16:16:02 -05:00
parent 9af13c5bb4
commit a6a5edcc40

View File

@ -188,10 +188,14 @@ impl StateMachine {
}
state.recipe_counts = plan_map;
} else {
// Initialize things to zero
if let Some(rs) = recipe_entries {
for r in rs {
state.recipe_counts.insert(r.recipe_id().to_owned(), 0);
if let Some(plan) = local_store.get_plan() {
state.recipe_counts = plan.iter().map(|(k, v)| (k.clone(), *v as usize)).collect();
} else {
// Initialize things to zero.
if let Some(rs) = recipe_entries {
for r in rs {
state.recipe_counts.insert(r.recipe_id().to_owned(), 0);
}
}
}
}