From cf05597a3087d0f9c467d4aa8060e03db39ea2f7 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Fri, 28 Jun 2024 19:07:13 +0200 Subject: [PATCH] Cleanup the not finished tasks --- snow-scanner/src/main.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/snow-scanner/src/main.rs b/snow-scanner/src/main.rs index a2cc04a..e66b24a 100644 --- a/snow-scanner/src/main.rs +++ b/snow-scanner/src/main.rs @@ -545,6 +545,11 @@ fn main() -> Result<()> { thread::spawn(move || { let conn = get_connection(db_file.as_str()); + // Reset scan tasks + let _ = conn.execute("UPDATE scan_tasks SET updated_at = :updated_at, still_processing_at = NULL, started_at = NULL WHERE (still_processing_at IS NOT NULL OR started_at IS NOT NULL) AND ended_at IS NULL", + named_params! { + ":updated_at": Utc::now().naive_utc().to_string(), + }).unwrap(); loop { let mut stmt = conn.prepare("SELECT task_group_id, cidr FROM scan_tasks WHERE started_at IS NULL ORDER BY created_at ASC").unwrap();