From 844e2c1f8c743a26c040fcdc9c0f5f4a0c3a6496 Mon Sep 17 00:00:00 2001 From: philipp Date: Sun, 12 Nov 2023 21:28:06 +0100 Subject: [PATCH] add timestamp to save imgs --- src/tera/ergo.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/tera/ergo.rs b/src/tera/ergo.rs index e0fb3b1..8b00446 100644 --- a/src/tera/ergo.rs +++ b/src/tera/ergo.rs @@ -1,5 +1,6 @@ use std::env; +use chrono::Utc; use rocket::{ form::Form, fs::TempFile, @@ -148,7 +149,11 @@ async fn new_thirty( return Flash::error(Redirect::to("/ergo"), "Es werden nur JPG Bilder akzeptiert"); }; let base_dir = env::current_dir().unwrap(); - let file_path = base_dir.join(format!("data-ergo/thirty/{}.{extension}", user.name)); + let file_path = base_dir.join(format!( + "data-ergo/thirty/{}_{}.{extension}", + user.name, + Utc::now() + )); if let Err(e) = data.proof.move_copy_to(file_path).await { eprintln!("Failed to persist file: {:?}", e); } @@ -185,7 +190,11 @@ async fn new_dozen( return Flash::error(Redirect::to("/ergo"), "Es werden nur JPG Bilder akzeptiert"); }; let base_dir = env::current_dir().unwrap(); - let file_path = base_dir.join(format!("data-ergo/dozen/{}.{extension}", user.name)); + let file_path = base_dir.join(format!( + "data-ergo/dozen/{}_{}.{extension}", + user.name, + Utc::now() + )); if let Err(e) = data.proof.move_copy_to(file_path).await { eprintln!("Failed to persist file: {:?}", e); }