refactor(ocr): get rid of unused clean up

This commit is contained in:
Elian Doran
2026-04-02 20:23:03 +03:00
parent 476396da53
commit bb23b08b15
7 changed files with 0 additions and 55 deletions

View File

@@ -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');
});
});
});

View File

@@ -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
*/

View File

@@ -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();
}
}

View File

@@ -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

View File

@@ -53,7 +53,4 @@ export class OfficeProcessor extends FileProcessor {
return 'office';
}
async cleanup(): Promise<void> {
// Nothing to clean up.
}
}

View File

@@ -35,7 +35,4 @@ export class PDFProcessor extends FileProcessor {
return 'pdf';
}
async cleanup(): Promise<void> {
// Nothing to clean up.
}
}

View File

@@ -86,7 +86,4 @@ export class TIFFProcessor extends FileProcessor {
return 'tiff';
}
async cleanup(): Promise<void> {
await this.imageProcessor.cleanup();
}
}