backend opti
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user