mirror of
				https://github.com/immich-app/immich.git
				synced 2025-11-03 19:17:11 -05:00 
			
		
		
		
	fix(server): duplicate faces bug (#4844)
This commit is contained in:
		
							parent
							
								
									cf1dfdc776
								
							
						
					
					
						commit
						e671b30aaf
					
				@ -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 { BadRequestException, NotFoundException } from '@nestjs/common';
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
  IAccessRepositoryMock,
 | 
					  IAccessRepositoryMock,
 | 
				
			||||||
@ -449,6 +449,23 @@ describe(PersonService.name, () => {
 | 
				
			|||||||
      expect(machineLearningMock.detectFaces).not.toHaveBeenCalled();
 | 
					      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 () => {
 | 
					    it('should handle no results', async () => {
 | 
				
			||||||
      machineLearningMock.detectFaces.mockResolvedValue([]);
 | 
					      machineLearningMock.detectFaces.mockResolvedValue([]);
 | 
				
			||||||
      assetMock.getByIds.mockResolvedValue([assetStub.image]);
 | 
					      assetMock.getByIds.mockResolvedValue([assetStub.image]);
 | 
				
			||||||
 | 
				
			|||||||
@ -217,7 +217,7 @@ export class PersonService {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const [asset] = await this.assetRepository.getByIds([id]);
 | 
					    const [asset] = await this.assetRepository.getByIds([id]);
 | 
				
			||||||
    if (!asset || !asset.resizePath) {
 | 
					    if (!asset || !asset.resizePath || asset.faces?.length > 0) {
 | 
				
			||||||
      return false;
 | 
					      return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user