Fix possible crashes on .unwrap()s

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2024-03-11 20:15:19 +00:00
parent 7bacc2565a
commit 2d8972dce2
5 changed files with 18 additions and 8 deletions

View File

@@ -57,7 +57,7 @@ impl super::Handler for Handler {
}
async fn queue_backfill(&self, jobs: &HashMap<String, Job>) {
if *ALPACA_SOURCE == Source::Sip {
if jobs.is_empty() || *ALPACA_SOURCE == Source::Sip {
return;
}
@@ -71,6 +71,10 @@ impl super::Handler for Handler {
#[allow(clippy::too_many_lines)]
async fn backfill(&self, jobs: HashMap<String, Job>) {
if jobs.is_empty() {
return;
}
let symbols = jobs.keys().cloned().collect::<Vec<_>>();
let fetch_from = jobs.values().map(|job| job.fetch_from).min().unwrap();
let fetch_to = jobs.values().map(|job| job.fetch_to).max().unwrap();