mirror of
https://github.com/zadam/trilium.git
synced 2026-06-26 19:21:42 +02:00
refactor(ocr): get rid of unused clean up
This commit is contained in:
@@ -804,20 +804,4 @@ describe('OCRService', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('cleanup', () => {
|
||||
it('should terminate worker on cleanup', async () => {
|
||||
|
||||
await ocrService.cleanup();
|
||||
|
||||
expect(mockWorker.terminate).toHaveBeenCalled();
|
||||
expect(mockLog.info).toHaveBeenCalledWith('OCR service cleaned up');
|
||||
});
|
||||
|
||||
it('should handle cleanup when worker is not initialized', async () => {
|
||||
await ocrService.cleanup();
|
||||
|
||||
expect(mockWorker.terminate).not.toHaveBeenCalled();
|
||||
expect(mockLog.info).toHaveBeenCalledWith('OCR service cleaned up');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { getTesseractCode } from '@triliumnext/commons';
|
||||
import Tesseract from 'tesseract.js';
|
||||
|
||||
import becca from '../../becca/becca.js';
|
||||
import blobService from '../blob.js';
|
||||
@@ -38,7 +37,6 @@ interface OCRBlobRow {
|
||||
* Uses Tesseract.js for text recognition
|
||||
*/
|
||||
class OCRService {
|
||||
private worker: Tesseract.Worker | null = null;
|
||||
private isProcessing = false;
|
||||
private processors: Map<string, FileProcessor> = new Map();
|
||||
|
||||
@@ -382,17 +380,6 @@ class OCRService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up OCR service
|
||||
*/
|
||||
async cleanup(): Promise<void> {
|
||||
if (this.worker) {
|
||||
await this.worker.terminate();
|
||||
this.worker = null;
|
||||
}
|
||||
log.info('OCR service cleaned up');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if currently processing
|
||||
*/
|
||||
|
||||
@@ -23,11 +23,4 @@ export abstract class FileProcessor {
|
||||
* Get list of MIME types supported by this processor
|
||||
*/
|
||||
abstract getSupportedMimeTypes(): string[];
|
||||
|
||||
/**
|
||||
* Clean up any resources
|
||||
*/
|
||||
cleanup(): Promise<void> {
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
@@ -90,16 +90,6 @@ export class ImageProcessor extends FileProcessor {
|
||||
this.currentLanguage = language;
|
||||
}
|
||||
|
||||
async cleanup(): Promise<void> {
|
||||
if (this.worker) {
|
||||
await this.worker.terminate();
|
||||
this.worker = null;
|
||||
}
|
||||
this.currentLanguage = null;
|
||||
log.info('Image OCR processor cleaned up');
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Filter text based on minimum confidence threshold
|
||||
|
||||
@@ -53,7 +53,4 @@ export class OfficeProcessor extends FileProcessor {
|
||||
return 'office';
|
||||
}
|
||||
|
||||
async cleanup(): Promise<void> {
|
||||
// Nothing to clean up.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,4 @@ export class PDFProcessor extends FileProcessor {
|
||||
return 'pdf';
|
||||
}
|
||||
|
||||
async cleanup(): Promise<void> {
|
||||
// Nothing to clean up.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +86,4 @@ export class TIFFProcessor extends FileProcessor {
|
||||
return 'tiff';
|
||||
}
|
||||
|
||||
async cleanup(): Promise<void> {
|
||||
await this.imageProcessor.cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user