From ba10bf7628b049ad8c91c01edd78d58a81bf55d4 Mon Sep 17 00:00:00 2001 From: mertalev <101130780+mertalev@users.noreply.github.com> Date: Thu, 21 Nov 2024 01:44:21 -0500 Subject: [PATCH] set exiftool maxProcs --- server/src/interfaces/metadata.interface.ts | 1 + server/src/repositories/metadata.repository.ts | 4 ++++ server/src/services/metadata.service.ts | 10 ++++++++++ 3 files changed, 15 insertions(+) diff --git a/server/src/interfaces/metadata.interface.ts b/server/src/interfaces/metadata.interface.ts index 574420e27a..2a0a13e352 100644 --- a/server/src/interfaces/metadata.interface.ts +++ b/server/src/interfaces/metadata.interface.ts @@ -64,6 +64,7 @@ export interface ImmichTags extends Omit { } export interface IMetadataRepository { + setMaxConcurrency(concurrency: number): void; teardown(): Promise; readTags(path: string): Promise; writeTags(path: string, tags: Partial): Promise; diff --git a/server/src/repositories/metadata.repository.ts b/server/src/repositories/metadata.repository.ts index 81c1b35e15..768a0f0f31 100644 --- a/server/src/repositories/metadata.repository.ts +++ b/server/src/repositories/metadata.repository.ts @@ -24,6 +24,10 @@ export class MetadataRepository implements IMetadataRepository { this.logger.setContext(MetadataRepository.name); } + setMaxConcurrency(concurrency: number) { + this.exiftool.batchCluster.setMaxProcs(concurrency); + } + async teardown() { await this.exiftool.end(); } diff --git a/server/src/services/metadata.service.ts b/server/src/services/metadata.service.ts index b6f1a3beaf..5da2297978 100644 --- a/server/src/services/metadata.service.ts +++ b/server/src/services/metadata.service.ts @@ -80,6 +80,16 @@ export class MetadataService extends BaseService { await this.metadataRepository.teardown(); } + @OnEvent({ name: 'config.init', workers: [ImmichWorker.MICROSERVICES] }) + onConfigInit({ newConfig }: ArgOf<'config.init'>) { + this.metadataRepository.setMaxConcurrency(newConfig.job.metadataExtraction.concurrency); + } + + @OnEvent({ name: 'config.update', workers: [ImmichWorker.MICROSERVICES], server: true }) + onConfigUpdate({ newConfig }: ArgOf<'config.update'>) { + this.metadataRepository.setMaxConcurrency(newConfig.job.metadataExtraction.concurrency); + } + private async init() { this.logger.log('Initializing metadata service');