diff --git a/server/src/domain/person/person.service.spec.ts b/server/src/domain/person/person.service.spec.ts index 9d966460e1..59b33f4dc6 100644 --- a/server/src/domain/person/person.service.spec.ts +++ b/server/src/domain/person/person.service.spec.ts @@ -1,4 +1,4 @@ -import { Colorspace, SystemConfigKey } from '@app/infra/entities'; +import { AssetFaceEntity, Colorspace, SystemConfigKey } from '@app/infra/entities'; import { BadRequestException, NotFoundException } from '@nestjs/common'; import { IAccessRepositoryMock, @@ -449,6 +449,23 @@ describe(PersonService.name, () => { expect(machineLearningMock.detectFaces).not.toHaveBeenCalled(); }); + it('should skip it the asset has already been processed', async () => { + assetMock.getByIds.mockResolvedValue([ + { + ...assetStub.noResizePath, + faces: [ + { + id: 'asset-face-1', + assetId: assetStub.noResizePath.id, + personId: faceStub.face1.personId, + } as AssetFaceEntity, + ], + }, + ]); + await sut.handleRecognizeFaces({ id: assetStub.noResizePath.id }); + expect(machineLearningMock.detectFaces).not.toHaveBeenCalled(); + }); + it('should handle no results', async () => { machineLearningMock.detectFaces.mockResolvedValue([]); assetMock.getByIds.mockResolvedValue([assetStub.image]); diff --git a/server/src/domain/person/person.service.ts b/server/src/domain/person/person.service.ts index dcf5dbb78d..b6e7bf0b9f 100644 --- a/server/src/domain/person/person.service.ts +++ b/server/src/domain/person/person.service.ts @@ -217,7 +217,7 @@ export class PersonService { } const [asset] = await this.assetRepository.getByIds([id]); - if (!asset || !asset.resizePath) { + if (!asset || !asset.resizePath || asset.faces?.length > 0) { return false; }