1
0
forked from Cutlery/immich

don't double batch

This commit is contained in:
Jonathan Jogenfors 2024-03-17 00:30:13 +01:00
parent 5bc22d5854
commit 3f56cbeddf

View File

@ -303,11 +303,8 @@ export class LibraryService extends EventEmitter {
private async scanAssets(libraryId: string, assetPaths: string[], ownerId: string, force = false) { private async scanAssets(libraryId: string, assetPaths: string[], ownerId: string, force = false) {
this.logger.verbose(`Queuing refresh of ${assetPaths.length} asset(s)`); this.logger.verbose(`Queuing refresh of ${assetPaths.length} asset(s)`);
// We perform this in batches to save on memory when performing large refreshes (greater than 1M assets)
for (let i = 0; i < assetPaths.length; i += LIBRARY_SCAN_BATCH_SIZE) {
const batch = assetPaths.slice(i, i + LIBRARY_SCAN_BATCH_SIZE);
await this.jobRepository.queueAll( await this.jobRepository.queueAll(
batch.map((assetPath) => ({ assetPaths.map((assetPath) => ({
name: JobName.LIBRARY_SCAN_ASSET, name: JobName.LIBRARY_SCAN_ASSET,
data: { data: {
id: libraryId, id: libraryId,
@ -317,9 +314,8 @@ export class LibraryService extends EventEmitter {
}, },
})), })),
); );
}
this.logger.debug('Asset refresh queue completed'); this.logger.verbose('Asset refresh queued');
} }
private async validateImportPath(importPath: string): Promise<ValidateLibraryImportPathResponseDto> { private async validateImportPath(importPath: string): Promise<ValidateLibraryImportPathResponseDto> {