From 3df5b5ef1d08aec67878bb0dbb870ff89fe728fd Mon Sep 17 00:00:00 2001 From: perf3ct Date: Tue, 15 Jul 2025 15:57:14 +0000 Subject: [PATCH] fix(client): also resolve missing thumbnails --- src/routes/documents/debug.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/routes/documents/debug.rs b/src/routes/documents/debug.rs index 8e18078..f064b3b 100644 --- a/src/routes/documents/debug.rs +++ b/src/routes/documents/debug.rs @@ -137,9 +137,9 @@ pub async fn get_document_thumbnail( let file_service = FileService::new(state.config.upload_path.clone()); - // Try to read thumbnail from the thumbnails directory - let thumbnail_path = format!("{}/thumbnails/{}.jpg", state.config.upload_path, document.id); - match file_service.read_file(&thumbnail_path).await { + // Use the FileService to get or generate thumbnail + #[cfg(feature = "ocr")] + match file_service.get_or_generate_thumbnail(&document.file_path, &document.original_filename).await { Ok(data) => { let response = axum::response::Response::builder() .status(StatusCode::OK) @@ -155,11 +155,17 @@ pub async fn get_document_thumbnail( debug!("Thumbnail served for document: {}", document_id); Ok(response) } - Err(_) => { - // Return a default "no thumbnail" response or generate one on the fly + Err(e) => { + error!("Failed to get or generate thumbnail for document {}: {}", document_id, e); 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)