High performance self-hosted photo and video management solution.
TypeScript backup-toolfluttergoogle-photosgoogle-photos-alternativejavascriptmobile-appnestjsnodejsphoto-galleryphotosphotos-managementself-hostedsveltesveltekittypescriptvideos
fix: queue in batches (#17989)
Jason Rasmussen0c261ffbe2e2
diff --git a/server/src/services/media.service.ts b/server/src/services/media.service.tsindex a0bc1b0906..a50b5b709d 100644--- a/server/src/services/media.service.ts+++ b/server/src/services/media.service.ts@@ -50,18 +50,26 @@ export class MediaService extends BaseService {@OnJob({ name: JobName.QUEUE_GENERATE_THUMBNAILS, queue: QueueName.THUMBNAIL_GENERATION })async handleQueueGenerateThumbnails({ force }: JobOf<JobName.QUEUE_GENERATE_THUMBNAILS>): Promise<JobStatus> {- const thumbJobs: JobItem[] = [];+ let jobs: JobItem[] = [];++ const queueAll = async () => {+ await this.jobRepository.queueAll(jobs);+ jobs = [];+ };+for await (const asset of this.assetJobRepository.streamForThumbnailJob(!!force)) {const { previewFile, thumbnailFile } = getAssetFiles(asset.files);if (!previewFile || !thumbnailFile || !asset.thumbhash || force) {- thumbJobs.push({ name: JobName.GENERATE_THUMBNAILS, data: { id: asset.id } });- continue;+ jobs.push({ name: JobName.GENERATE_THUMBNAILS, data: { id: asset.id } });+ }++ if (jobs.length >= JOBS_ASSET_PAGINATION_SIZE) {+ await queueAll();}}- await this.jobRepository.queueAll(thumbJobs);- const jobs: JobItem[] = [];+ await queueAll();const people = this.personRepository.getAll(force ? undefined : { thumbnailPath: '' });@@ -76,9 +84,12 @@ export class MediaService extends BaseService {}jobs.push({ name: JobName.GENERATE_PERSON_THUMBNAIL, data: { id: person.id } });+ if (jobs.length >= JOBS_ASSET_PAGINATION_SIZE) {+ await queueAll();+ }}- await this.jobRepository.queueAll(jobs);+ await queueAll();return JobStatus.SUCCESS;}