From 4f896d8ada84d975868c9fb04573e09922346224 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arma=C3=ABl=20Gu=C3=A9neau?= Date: Fri, 20 Dec 2024 10:19:54 +0100 Subject: [PATCH] run workers on startup instead of sleeping first --- src/workers.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/workers.rs b/src/workers.rs index b4ae437..fa065c3 100644 --- a/src/workers.rs +++ b/src/workers.rs @@ -70,10 +70,10 @@ pub async fn refresh_user_data( classifier: Arc>, ) { loop { - tokio::time::sleep(FORGEJO_POLL_DELAY.mul_f32(0.1)).await; if let Err(e) = try_refresh_user_data(&forge, db.clone(), classifier.clone()).await { eprintln!("Error refreshing user data: {:?}", e); } + tokio::time::sleep(FORGEJO_POLL_DELAY.mul_f32(0.1)).await; } } @@ -91,8 +91,6 @@ async fn try_purge_account(forge: &Forgejo, login: &str) -> anyhow::Result<()> { pub async fn purge_spammer_accounts(forge: Arc, db: Arc>) { loop { - tokio::time::sleep(std::time::Duration::from_secs(3600)).await; - let mut classified_users = Vec::new(); { let db = &db.lock().unwrap(); @@ -121,5 +119,7 @@ pub async fn purge_spammer_accounts(forge: Arc, db: Arc>) { } } } + + tokio::time::sleep(std::time::Duration::from_secs(3600)).await; } }