From e5eba69d0d8690bb695a125fdbf120f541fde30b Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Thu, 2 Apr 2026 12:51:58 +0300 Subject: [PATCH] fix(ocr): cannot handle image/tiff --- apps/server/src/services/ocr/ocr_service.ts | 42 +++++++-------------- 1 file changed, 14 insertions(+), 28 deletions(-) diff --git a/apps/server/src/services/ocr/ocr_service.ts b/apps/server/src/services/ocr/ocr_service.ts index 5f4eb044c2..5999623fbc 100644 --- a/apps/server/src/services/ocr/ocr_service.ts +++ b/apps/server/src/services/ocr/ocr_service.ts @@ -170,24 +170,17 @@ class OCRService { return null; } - // Check if note type and MIME type are supported for OCR - if (note.type === 'image') { - if (!this.isSupportedMimeType(note.mime)) { - log.info(`Image note ${noteId} has unsupported MIME type ${note.mime}, skipping OCR`); - return null; - } - } else if (note.type === 'file') { - // Check if file MIME type is supported by any processor - const processor = this.getProcessorForMimeType(note.mime); - if (!processor) { - log.info(`File note ${noteId} has unsupported MIME type ${note.mime} for OCR, skipping`); - return null; - } - } else { + // Check if note type and MIME type are supported + if (!['image', 'file'].includes(note.type)) { log.info(`Note ${noteId} is not an image or file note, skipping OCR`); return null; } + if (!this.getProcessorForMimeType(note.mime)) { + log.info(`Note ${noteId} has unsupported MIME type ${note.mime} for text extraction, skipping`); + return null; + } + // Check if OCR already exists if (!options.forceReprocess) { const existingOCR = this.getStoredOCRResult(note.blobId); @@ -226,24 +219,17 @@ class OCRService { return null; } - // Check if attachment role and MIME type are supported for OCR - if (attachment.role === 'image') { - if (!this.isSupportedMimeType(attachment.mime)) { - log.info(`Image attachment ${attachmentId} has unsupported MIME type ${attachment.mime}, skipping OCR`); - return null; - } - } else if (attachment.role === 'file') { - // Check if file MIME type is supported by any processor - const processor = this.getProcessorForMimeType(attachment.mime); - if (!processor) { - log.info(`File attachment ${attachmentId} has unsupported MIME type ${attachment.mime} for OCR, skipping`); - return null; - } - } else { + // Check if attachment role and MIME type are supported + if (!['image', 'file'].includes(attachment.role)) { log.info(`Attachment ${attachmentId} is not an image or file, skipping OCR`); return null; } + if (!this.getProcessorForMimeType(attachment.mime)) { + log.info(`Attachment ${attachmentId} has unsupported MIME type ${attachment.mime} for text extraction, skipping`); + return null; + } + // Check if OCR already exists if (!options.forceReprocess) { const existingOCR = this.getStoredOCRResult(attachment.blobId);