From c53897891b06c243a91ebbf299ab72fc979556bb Mon Sep 17 00:00:00 2001 From: Nulo Date: Tue, 6 Feb 2024 13:20:56 -0300 Subject: [PATCH] save debug path with date --- .gitignore | 2 +- scraper-rs/src/main.rs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 8e5effc..4dbebe2 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,4 @@ target/ */flamegraph.svg */perf.data* -scraper-rs/debug/ \ No newline at end of file +scraper-rs/debug*/ \ No newline at end of file diff --git a/scraper-rs/src/main.rs b/scraper-rs/src/main.rs index 3968b12..d8d5519 100644 --- a/scraper-rs/src/main.rs +++ b/scraper-rs/src/main.rs @@ -1,4 +1,5 @@ use again::RetryPolicy; +use chrono::{DateTime, Utc}; use clap::{Parser, ValueEnum}; use cron::Schedule; use db::Db; @@ -202,7 +203,8 @@ async fn fetch_and_parse( let point = match maybe_point { Ok(p) => Ok(p), Err(err) => { - let debug_path = PathBuf::from("debug/"); + let now: DateTime = Utc::now(); + let debug_path = PathBuf::from(format!("debug-{}/", now.format("%Y-%m-%d"))); tokio::fs::create_dir_all(&debug_path).await.unwrap(); let file_path = debug_path.join(format!("{}.html", nanoid!())); tokio::fs::write(&file_path, &body).await.unwrap();