fix(client): also resolve missing thumbnails
This commit is contained in:
parent
8b23e8a1c1
commit
3df5b5ef1d
|
|
@ -137,9 +137,9 @@ pub async fn get_document_thumbnail(
|
||||||
|
|
||||||
let file_service = FileService::new(state.config.upload_path.clone());
|
let file_service = FileService::new(state.config.upload_path.clone());
|
||||||
|
|
||||||
// Try to read thumbnail from the thumbnails directory
|
// Use the FileService to get or generate thumbnail
|
||||||
let thumbnail_path = format!("{}/thumbnails/{}.jpg", state.config.upload_path, document.id);
|
#[cfg(feature = "ocr")]
|
||||||
match file_service.read_file(&thumbnail_path).await {
|
match file_service.get_or_generate_thumbnail(&document.file_path, &document.original_filename).await {
|
||||||
Ok(data) => {
|
Ok(data) => {
|
||||||
let response = axum::response::Response::builder()
|
let response = axum::response::Response::builder()
|
||||||
.status(StatusCode::OK)
|
.status(StatusCode::OK)
|
||||||
|
|
@ -155,11 +155,17 @@ pub async fn get_document_thumbnail(
|
||||||
debug!("Thumbnail served for document: {}", document_id);
|
debug!("Thumbnail served for document: {}", document_id);
|
||||||
Ok(response)
|
Ok(response)
|
||||||
}
|
}
|
||||||
Err(_) => {
|
Err(e) => {
|
||||||
// Return a default "no thumbnail" response or generate one on the fly
|
error!("Failed to get or generate thumbnail for document {}: {}", document_id, e);
|
||||||
Err(StatusCode::NOT_FOUND)
|
Err(StatusCode::NOT_FOUND)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "ocr"))]
|
||||||
|
{
|
||||||
|
error!("Thumbnail generation requires OCR feature to be enabled");
|
||||||
|
Err(StatusCode::NOT_FOUND)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get processed image for a document (if available)
|
/// Get processed image for a document (if available)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue