forked from Cutlery/immich
		
	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
					
				@ -787,6 +787,17 @@ describe(PersonService.name, () => {
 | 
				
			|||||||
      expect(personMock.createFaces).not.toHaveBeenCalled();
 | 
					      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 () => {
 | 
					    it('should return true if face already has an assigned person', async () => {
 | 
				
			||||||
      personMock.getFaceByIdWithAssets.mockResolvedValue(faceStub.face1);
 | 
					      personMock.getFaceByIdWithAssets.mockResolvedValue(faceStub.face1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -400,7 +400,7 @@ export class PersonService {
 | 
				
			|||||||
      { person: true, asset: true },
 | 
					      { person: true, asset: true },
 | 
				
			||||||
      { id: true, personId: true, embedding: true },
 | 
					      { id: true, personId: true, embedding: true },
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
    if (!face) {
 | 
					    if (!face || !face.asset) {
 | 
				
			||||||
      this.logger.warn(`Face ${id} not found`);
 | 
					      this.logger.warn(`Face ${id} not found`);
 | 
				
			||||||
      return false;
 | 
					      return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user