Merge branch 'save-ergo-imgs' into 'main'

add timestamp to save imgs

See merge request PhilippHofer/rot!114
This commit is contained in:
PhilippHofer 2023-11-12 20:41:31 +00:00
commit bcd275fc3e

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