hunter: set last_fetch on dequeue() not reenqueue()

This commit is contained in:
Astro 2023-03-03 20:47:14 +01:00
parent 41df64f408
commit 2f7b9a4b23
1 changed files with 6 additions and 2 deletions

View File

@ -65,7 +65,6 @@ impl Scheduler {
let instance = self.instances.get_mut(&host).unwrap();
let last_interval = instance.last_fetch.map(|last_fetch| now - last_fetch);
instance.last_fetch = Some(now);
instance.error = false;
let next_interval = match (new_post_ratio, mean_interval, last_interval) {
@ -94,7 +93,12 @@ impl Scheduler {
if let Some(time) = self.queue.keys().next().cloned() {
if time <= now {
self.queue.remove(&time)
.map(|host| Ok(host))
.map(|host| {
self.instances.get_mut(&host)
.map(|instance| instance.last_fetch = Some(now));
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) {