1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2025-01-16 16:56:46 +01:00

fix(server): do not process faces of deleted assets (#6710)

* return if asset is not found

* add unit test

* formatting
This commit is contained in:
Mert 2024-01-28 20:17:54 -05:00 committed by GitHub
parent 28806d03e3
commit 0770ad15e5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 1 deletions

View file

@ -787,6 +787,17 @@ describe(PersonService.name, () => {
expect(personMock.createFaces).not.toHaveBeenCalled();
});
it('should return false if face does not have asset', async () => {
const face = { ...faceStub.face1, asset: null } as AssetFaceEntity & { asset: null };
personMock.getFaceByIdWithAssets.mockResolvedValue(face);
expect(await sut.handleRecognizeFaces({ id: faceStub.face1.id })).toBe(false);
expect(personMock.reassignFaces).not.toHaveBeenCalled();
expect(personMock.create).not.toHaveBeenCalled();
expect(personMock.createFaces).not.toHaveBeenCalled();
});
it('should return true if face already has an assigned person', async () => {
personMock.getFaceByIdWithAssets.mockResolvedValue(faceStub.face1);

View file

@ -400,7 +400,7 @@ export class PersonService {
{ person: true, asset: true },
{ id: true, personId: true, embedding: true },
);
if (!face) {
if (!face || !face.asset) {
this.logger.warn(`Face ${id} not found`);
return false;
}