diff --git a/server/src/repositories/integrity.repository.ts b/server/src/repositories/integrity.repository.ts index 80555396e2..1d167cf708 100644 --- a/server/src/repositories/integrity.repository.ts +++ b/server/src/repositories/integrity.repository.ts @@ -146,7 +146,12 @@ export class IntegrityRepository { ), ) .select(['allPaths.path as path', 'allPaths.assetId', 'allPaths.fileAssetId', 'integrity_report.id as reportId']) - .stream(); + .stream() as AsyncIterableIterator< + { path: string; reportId: string | null } & ( + | { assetId: string; fileAssetId: null } + | { assetId: null; fileAssetId: string } + ) + >; } @GenerateSql({ params: [DummyValue.DATE, DummyValue.DATE], stream: true }) diff --git a/server/src/types.ts b/server/src/types.ts index dcff5b3ca5..543add2461 100644 --- a/server/src/types.ts +++ b/server/src/types.ts @@ -301,12 +301,10 @@ export interface IIntegrityUntrackedFilesJob { } export interface IIntegrityMissingFilesJob { - items: { - path: string; - reportId: string | null; - assetId: string | null; - fileAssetId: string | null; - }[]; + items: ({ path: string; reportId: string | null } & ( + | { assetId: string; fileAssetId: null } + | { assetId: null; fileAssetId: string } + ))[]; } export interface IIntegrityPathWithReportJob { diff --git a/server/test/medium/specs/services/integrity.service.spec.ts b/server/test/medium/specs/services/integrity.service.spec.ts index ac9bb7c7e9..89e2135662 100644 --- a/server/test/medium/specs/services/integrity.service.spec.ts +++ b/server/test/medium/specs/services/integrity.service.spec.ts @@ -468,9 +468,18 @@ describe(IntegrityService.name, () => { const integrity = ctx.get(IntegrityRepository); const storage = ctx.getMock(StorageRepository); + const { + result: { id: ownerId }, + } = await ctx.newUser(); + + const { + result: { id: assetId }, + } = await ctx.newAsset({ ownerId, originalPath: '/path/to/file1' }); + const { id: restoredId } = await integrity.create({ type: IntegrityReportType.MissingFile, path: '/path/to/restored', + assetId, }); storage.stat @@ -480,9 +489,9 @@ describe(IntegrityService.name, () => { await sut.handleMissingFiles({ items: [ - { path: '/path/to/existing', assetId: null, fileAssetId: null, reportId: null }, - { path: '/path/to/missing', assetId: null, fileAssetId: null, reportId: null }, - { path: '/path/to/restored', assetId: null, fileAssetId: null, reportId: restoredId }, + { path: '/path/to/existing', assetId, fileAssetId: null, reportId: null }, + { path: '/path/to/missing', assetId, fileAssetId: null, reportId: null }, + { path: '/path/to/restored', assetId, fileAssetId: null, reportId: restoredId }, ], });