Skip to content

High performance self-hosted photo and video management solution.

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

Mert0770ad15e590
diff --git a/server/src/domain/person/person.service.spec.ts b/server/src/domain/person/person.service.spec.ts
index 23936a5735..d5b7a27d7a 100644
--- a/server/src/domain/person/person.service.spec.ts
+++ b/server/src/domain/person/person.service.spec.ts
@@ -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);
diff --git a/server/src/domain/person/person.service.ts b/server/src/domain/person/person.service.ts
index c4bbd8d1c7..39c7eb9439 100644
--- a/server/src/domain/person/person.service.ts
+++ b/server/src/domain/person/person.service.ts
@@ -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;
}