From bf7fb810de5beab71c2039be1e89dfd513bddfe8 Mon Sep 17 00:00:00 2001 From: Cameron Cordes Date: Wed, 17 Jan 2024 20:45:36 -0500 Subject: [PATCH] Fix duplicate file naming --- src/main.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 9c0b402..4cbe894 100644 --- a/src/main.rs +++ b/src/main.rs @@ -169,13 +169,18 @@ async fn upload_image( warn!("File already exists: {:?}", full_path); let new_path = format!( - "{:?}_{}.{:?}", - full_path.file_stem(), - Utc::now(), + "{}/{}_{}.{}", + full_path.parent().unwrap().to_str().unwrap(), + full_path.file_stem().unwrap().to_str().unwrap(), + Utc::now().timestamp(), full_path .extension() .expect("Uploaded file should have an extension") + .to_str() + .unwrap() ); + info!("Uploaded: {}", new_path); + let mut file = File::create(new_path).unwrap(); file.write_all(&file_content).unwrap();