mirror of
https://github.com/immich-app/immich.git
synced 2025-05-31 04:05:39 -04:00
fix: queue in batches (#17989)
This commit is contained in:
parent
6df6103c67
commit
0c261ffbe2
@ -50,18 +50,26 @@ export class MediaService extends BaseService {
|
|||||||
|
|
||||||
@OnJob({ name: JobName.QUEUE_GENERATE_THUMBNAILS, queue: QueueName.THUMBNAIL_GENERATION })
|
@OnJob({ name: JobName.QUEUE_GENERATE_THUMBNAILS, queue: QueueName.THUMBNAIL_GENERATION })
|
||||||
async handleQueueGenerateThumbnails({ force }: JobOf<JobName.QUEUE_GENERATE_THUMBNAILS>): Promise<JobStatus> {
|
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)) {
|
for await (const asset of this.assetJobRepository.streamForThumbnailJob(!!force)) {
|
||||||
const { previewFile, thumbnailFile } = getAssetFiles(asset.files);
|
const { previewFile, thumbnailFile } = getAssetFiles(asset.files);
|
||||||
|
|
||||||
if (!previewFile || !thumbnailFile || !asset.thumbhash || force) {
|
if (!previewFile || !thumbnailFile || !asset.thumbhash || force) {
|
||||||
thumbJobs.push({ name: JobName.GENERATE_THUMBNAILS, data: { id: asset.id } });
|
jobs.push({ name: JobName.GENERATE_THUMBNAILS, data: { id: asset.id } });
|
||||||
continue;
|
}
|
||||||
|
|
||||||
|
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: '' });
|
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 } });
|
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;
|
return JobStatus.SUCCESS;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user