backend opti

This commit is contained in:
2026-05-14 18:34:07 +02:00
parent 8f4556b968
commit 2a6a4e6483
6 changed files with 301 additions and 36 deletions
+10 -3
View File
@@ -89,6 +89,11 @@ pub async fn delete_upload(
error!("Delete error for file {}: {}", filename, e);
AppError::Internal("Delete error".to_string(), Some(e.to_string()))
})?;
state
.image_dims_cache
.write()
.await
.remove(&format!("/uploads/{}", filename));
info!("Deleted file: {}", filename);
Ok(StatusCode::NO_CONTENT)
} else {
@@ -227,10 +232,12 @@ pub async fn upload_file(
AppError::Internal("Write error".to_string(), Some(e.to_string()))
})?;
let url = format!("/uploads/{}", final_name_str);
// Invalidate any stale dim cache entry (matters when replacing an existing file).
state.image_dims_cache.write().await.remove(&url);
info!("File uploaded successfully to {:?}", final_path);
return Ok(Json(UploadResponse {
url: format!("/uploads/{}", final_name_str),
}));
return Ok(Json(UploadResponse { url }));
}
warn!("Upload failed: no file found in multipart stream");