From dd8d1133344f2aa251511b8e101d3a3fd35d8412 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 11 Apr 2023 08:56:52 -0500 Subject: [PATCH] fix(server): jobs using stale path (#2233) * fix(server): jobs using stale path * fixed test * pr feedback --- server/libs/domain/src/media/media.service.spec.ts | 4 ++++ server/libs/domain/src/media/media.service.ts | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/server/libs/domain/src/media/media.service.spec.ts b/server/libs/domain/src/media/media.service.spec.ts index bdb6b1eefd..81b55638f3 100644 --- a/server/libs/domain/src/media/media.service.spec.ts +++ b/server/libs/domain/src/media/media.service.spec.ts @@ -213,6 +213,10 @@ describe(MediaService.name, () => { }); describe('handleVideoConversion', () => { + beforeEach(() => { + assetMock.getByIds.mockResolvedValue([assetEntityStub.video]); + }); + it('should log an error', async () => { mediaMock.transcode.mockRejectedValue(new Error('unable to transcode')); diff --git a/server/libs/domain/src/media/media.service.ts b/server/libs/domain/src/media/media.service.ts index 5af30ef9ad..c32e8376ff 100644 --- a/server/libs/domain/src/media/media.service.ts +++ b/server/libs/domain/src/media/media.service.ts @@ -119,7 +119,11 @@ export class MediaService { } async handleVideoConversion(job: IAssetJob) { - const { asset } = job; + const [asset] = await this.assetRepository.getByIds([job.asset.id]); + + if (!asset) { + return; + } try { const input = asset.originalPath;