Skip to content

Commit

Permalink
feat: check if session folder exist
Browse files Browse the repository at this point in the history
  • Loading branch information
zeldan committed Aug 6, 2024
1 parent 4f44330 commit 241aee7
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ async fn main() {
.add(
Job::new_async("0 * * * * *", |_uuid, _l| {
Box::pin(async move {
let paths = fs::read_dir("./sessions").unwrap();
for path in paths {
let paths = fs::read_dir("./sessions");
if paths.is_err() {
tracing::info!("Sessions folder does not exist");
return;
}
for path in paths.unwrap() {
let full_folder_path = path.unwrap().path();
if full_folder_path.metadata().unwrap().is_file() {
continue;
Expand All @@ -43,7 +47,7 @@ async fn main() {
let _ = fs::remove_dir_all(full_folder_path);
}
}
tracing::info!("Cleaning folders older than 3 days...");
tracing::info!("Finished cleaning folders older than 3 days...");
})
})
.unwrap(),
Expand Down

0 comments on commit 241aee7

Please sign in to comment.