add timestamp to save imgs

This commit is contained in:
philipp 2023-11-12 21:28:06 +01:00
parent 9983d0f14a
commit 844e2c1f8c

View File

@ -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);
}