diff --git a/src/main.rs b/src/main.rs index c46f223..0854aee 100644 --- a/src/main.rs +++ b/src/main.rs @@ -92,7 +92,7 @@ async fn main() -> anyhow::Result<()> { &node_clone.url, &node_clone.origin, &id_clone, - date_path.clone().join(&id_clone), + date_path.clone(), config.webp_quality, ) .instrument(span) diff --git a/src/shotter.rs b/src/shotter.rs index 06f7617..0b9c1d4 100644 --- a/src/shotter.rs +++ b/src/shotter.rs @@ -84,6 +84,8 @@ pub async fn take_one_screenshot( .in_current_span(), ); + let node_name_clone = node_name.clone(); + // main handler let write_guac_handler_clone = write_tx.clone(); let guac_handler: JoinHandle> = tokio::spawn( @@ -114,13 +116,13 @@ pub async fn take_one_screenshot( let zone = tzfile::Tz::named("GMT")?; let now = { chrono::Utc::now().with_timezone(&&zone) }; - let file_path = root_path.join(format!( - "{:02}-{:02}-{:02}.webp", - now.hour(), - now.minute(), - now.second() - )); - + let file_path = + root_path.join(&node_name_clone).join(format!( + "{:02}-{:02}-{:02}.webp", + now.hour(), + now.minute(), + now.second() + )); let file_path_clone = file_path.clone(); @@ -149,8 +151,8 @@ pub async fn take_one_screenshot( let encoder = webp::Encoder::from_image(&image) .expect("fuck you"); - if !file_path_clone.exists() { - std::fs::create_dir_all(&file_path_clone)?; + if !root_path.exists() { + std::fs::create_dir_all(&root_path)?; } let mut file =