High performance self-hosted photo and video management solution.
TypeScript backup-toolfluttergoogle-photosgoogle-photos-alternativejavascriptmobile-appnestjsnodejsphoto-galleryphotosphotos-managementself-hostedsveltesveltekittypescriptvideos
fix(server): generate thumbnail job uses stale path (#2236)
Alexeb9481b66864
diff --git a/server/libs/domain/src/media/media.service.spec.ts b/server/libs/domain/src/media/media.service.spec.tsindex 81b55638f3..0697581770 100644--- a/server/libs/domain/src/media/media.service.spec.ts+++ b/server/libs/domain/src/media/media.service.spec.ts@@ -79,6 +79,7 @@ describe(MediaService.name, () => {describe('handleGenerateJpegThumbnail', () => {it('should generate a thumbnail for an image', async () => {+ assetMock.getByIds.mockResolvedValue([assetEntityStub.image]);await sut.handleGenerateJpegThumbnail({ asset: _.cloneDeep(assetEntityStub.image) });expect(storageMock.mkdirSync).toHaveBeenCalledWith('upload/thumbs/user-id');@@ -94,6 +95,7 @@ describe(MediaService.name, () => {});it('should generate a thumbnail for an image from exif', async () => {+ assetMock.getByIds.mockResolvedValue([assetEntityStub.image]);mediaMock.resize.mockRejectedValue(new Error('unsupported format'));await sut.handleGenerateJpegThumbnail({ asset: _.cloneDeep(assetEntityStub.image) });@@ -114,6 +116,7 @@ describe(MediaService.name, () => {});it('should generate a thumbnail for a video', async () => {+ assetMock.getByIds.mockResolvedValue([assetEntityStub.video]);await sut.handleGenerateJpegThumbnail({ asset: _.cloneDeep(assetEntityStub.video) });expect(storageMock.mkdirSync).toHaveBeenCalledWith('upload/thumbs/user-id');@@ -130,7 +133,7 @@ describe(MediaService.name, () => {it('should queue some jobs', async () => {const asset = _.cloneDeep(assetEntityStub.image);-+ assetMock.getByIds.mockResolvedValue([asset]);await sut.handleGenerateJpegThumbnail({ asset });expect(jobMock.queue).toHaveBeenCalledWith({ name: JobName.GENERATE_WEBP_THUMBNAIL, data: { asset } });@@ -140,6 +143,7 @@ describe(MediaService.name, () => {});it('should log an error', async () => {+ assetMock.getByIds.mockResolvedValue([assetEntityStub.image]);mediaMock.resize.mockRejectedValue(new Error('unsupported format'));mediaMock.extractThumbnailFromExif.mockRejectedValue(new Error('unsupported format'));diff --git a/server/libs/domain/src/media/media.service.ts b/server/libs/domain/src/media/media.service.tsindex c32e8376ff..81cae61fd4 100644--- a/server/libs/domain/src/media/media.service.ts+++ b/server/libs/domain/src/media/media.service.ts@@ -43,7 +43,14 @@ export class MediaService {}async handleGenerateJpegThumbnail(data: IAssetJob): Promise<void> {- const { asset } = data;+ const [asset] = await this.assetRepository.getByIds([data.asset.id]);++ if (!asset) {+ this.logger.warn(+ `Asset not found: ${data.asset.id} - Original Path: ${data.asset.originalPath} - Resize Path: ${data.asset.resizePath}`,+ );+ return;+ }try {const resizePath = this.storageCore.getFolderLocation(StorageFolder.THUMBNAILS, asset.ownerId);@@ -122,6 +129,7 @@ export class MediaService {const [asset] = await this.assetRepository.getByIds([job.asset.id]);if (!asset) {+ this.logger.warn(`Asset not found: ${job.asset.id} - Original Path: ${job.asset.originalPath}`);return;}