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:
parent
28806d03e3
commit
0770ad15e5
2 changed files with 12 additions and 1 deletions
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue