hunter/scheduler: fix fetch interval reporting

This commit is contained in:
Astro 2023-03-03 21:07:44 +01:00
parent 6231884d36
commit 08e920e247
1 changed files with 4 additions and 7 deletions

View File

@ -93,19 +93,16 @@ impl Scheduler {
if let Some(time) = self.queue.keys().next().cloned() {
if time <= now {
self.queue.remove(&time)
.map(|host| {
self.instances.get_mut(&host)
.map(|instance| instance.last_fetch = Some(now));
Ok(host)
})
.map(|host| Ok(host))
.unwrap_or(Err(Duration::from_secs(1)))
.map(|host| {
if let Some(last_fetch) = self.instances.get(&host).and_then(|i| i.last_fetch) {
let instance = self.instances.get_mut(&host);
if let Some(last_fetch) = instance.as_ref().and_then(|i| i.last_fetch) {
tracing::debug!("Fetch {} - last before {:.0?}", host, now - last_fetch);
} else {
tracing::debug!("Fetch {} - NEW", host);
}
instance.map(|instance| instance.last_fetch = Some(now));
host
})
} else {