From 99b02f30a2566efc54b99b368f45ff34ff44ade6 Mon Sep 17 00:00:00 2001 From: Araozu Date: Tue, 5 Dec 2023 15:39:43 -0500 Subject: [PATCH] [BE][Scans] Fixes #35. Rename file when there's an error detecting a QR --- backend/src/controller/scans/mod.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/backend/src/controller/scans/mod.rs b/backend/src/controller/scans/mod.rs index 20c5bfb..2daafc8 100644 --- a/backend/src/controller/scans/mod.rs +++ b/backend/src/controller/scans/mod.rs @@ -212,7 +212,19 @@ fn get_image_info(path: PathBuf) -> ScanInfo { Err(reason) => { log::error!("Error decoding qr: {:?}", reason); // Here there was a problem aligning the QR. Assume no QR - return ScanInfo::Empty(current_ms.to_string()); + + // Rename the file + let mut new_path = path.clone(); + new_path.set_file_name(format!("eeg_{}.jpg", current_ms)); + + return match fs::rename(path, new_path) { + Ok(_) => ScanInfo::Empty(current_ms.to_string()), + Err(err) => { + log::error!("Error renombrando archivo: {:?}", err); + + ScanInfo::Error("Error renombrando archivo.".into()) + } + } } };