From 01afeefeb9c828f30e1acbab87744dd54588dcf5 Mon Sep 17 00:00:00 2001 From: raisinbear <68740188+raisinbear@users.noreply.github.com> Date: Mon, 13 Mar 2023 18:42:05 +0100 Subject: [PATCH] fix(server): remove encoded video file on asset delete (#1980) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add check for encoded video file to be deleted with asset * remove unnecessary code and adjust test * complete test * fix unit test * fix unit test properly this time * fix formatting --------- Co-authored-by: Sebastian Schöttl --- .../immich/src/api-v1/asset/asset.service.spec.ts | 14 +++++++++++++- .../apps/immich/src/api-v1/asset/asset.service.ts | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/server/apps/immich/src/api-v1/asset/asset.service.spec.ts b/server/apps/immich/src/api-v1/asset/asset.service.spec.ts index e7d8760594..6d2e5f5abb 100644 --- a/server/apps/immich/src/api-v1/asset/asset.service.spec.ts +++ b/server/apps/immich/src/api-v1/asset/asset.service.spec.ts @@ -412,7 +412,16 @@ describe('AssetService', () => { expect(jobMock.queue).toHaveBeenCalledWith({ name: JobName.DELETE_FILES, data: { - files: ['fake_path/asset_1.jpeg', undefined, undefined, 'fake_path/asset_1.mp4', undefined, undefined], + files: [ + 'fake_path/asset_1.jpeg', + undefined, + undefined, + undefined, + 'fake_path/asset_1.mp4', + undefined, + undefined, + undefined, + ], }, }); }); @@ -430,6 +439,7 @@ describe('AssetService', () => { originalPath: 'original-path-2', resizePath: 'resize-path-2', webpPath: 'web-path-2', + encodedVideoPath: 'encoded-video-path-2', }; when(assetRepositoryMock.get) @@ -455,9 +465,11 @@ describe('AssetService', () => { 'original-path-1', 'web-path-1', 'resize-path-1', + undefined, 'original-path-2', 'web-path-2', 'resize-path-2', + 'encoded-video-path-2', ], }, }, diff --git a/server/apps/immich/src/api-v1/asset/asset.service.ts b/server/apps/immich/src/api-v1/asset/asset.service.ts index a04ec8a646..f3070637d6 100644 --- a/server/apps/immich/src/api-v1/asset/asset.service.ts +++ b/server/apps/immich/src/api-v1/asset/asset.service.ts @@ -430,7 +430,7 @@ export class AssetService { await this.jobRepository.queue({ name: JobName.SEARCH_REMOVE_ASSET, data: { id } }); result.push({ id, status: DeleteAssetStatusEnum.SUCCESS }); - deleteQueue.push(asset.originalPath, asset.webpPath, asset.resizePath); + deleteQueue.push(asset.originalPath, asset.webpPath, asset.resizePath, asset.encodedVideoPath); // TODO refactor this to use cascades if (asset.livePhotoVideoId && !ids.includes(asset.livePhotoVideoId)) {