fix(server): remove encoded video file on asset delete (#1980)

* 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 <sebastian.schoettl@cybertechnologies.com>
This commit is contained in:
raisinbear 2023-03-13 18:42:05 +01:00 committed by GitHub
parent 532bd6fe12
commit 01afeefeb9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View file

@ -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',
],
},
},

View file

@ -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)) {