diff --git a/src/util/sweeper.rs b/src/util/sweeper.rs index a2c1c3e..e346dbc 100644 --- a/src/util/sweeper.rs +++ b/src/util/sweeper.rs @@ -1,22 +1,28 @@ use std::time::Duration; +use tracing::{info_span, Instrument}; + use crate::state::AppState; /// Spawn a repeating task that will clean files periodically pub fn spawn(_state: AppState) { - tokio::spawn(async move { - loop { - tokio::time::sleep(Duration::from_secs(15 * 60)).await; - tracing::info!("Cleaning Sweep!"); + tokio::spawn( + async move { + loop { + tokio::time::sleep(Duration::from_secs(15 * 60)).await; - // let mut records = state.records.lock().await; - // - // for (key, record) in records.clone().into_iter() { - // if !record.can_be_downloaded() { - // tracing::info!("culling: {:?}", record); - // records.remove_record(&key).await.unwrap(); - // } - // } + tracing::info!("Cleaning Sweep!"); + + // let mut records = state.records.lock().await; + // + // for (key, record) in records.clone().into_iter() { + // if !record.can_be_downloaded() { + // tracing::info!("culling: {:?}", record); + // records.remove_record(&key).await.unwrap(); + // } + // } + } } - }); + .instrument(info_span!("sweeper")), + ); }