1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2024-12-28 22:51:59 +00:00

fix(server): duplicate faces, face insert query failing (#13294)

fix duplicate faces, query failing
This commit is contained in:
Mert 2024-10-08 17:37:41 -04:00 committed by GitHub
parent 9d0f03808c
commit 08d428cbce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 2 deletions

View file

@ -279,7 +279,7 @@ export class PersonRepository implements IPersonRepository {
faceIdsToRemove: string[],
embeddingsToAdd?: FaceSearchEntity[],
): Promise<void> {
const query = this.faceSearchRepository.createQueryBuilder().select('1');
const query = this.faceSearchRepository.createQueryBuilder().select('1').fromDummy();
if (facesToAdd.length > 0) {
const insertCte = this.assetFaceRepository.createQueryBuilder().insert().values(facesToAdd);
query.addCommonTableExpression(insertCte, 'added');
@ -296,6 +296,7 @@ export class PersonRepository implements IPersonRepository {
if (embeddingsToAdd?.length) {
const embeddingCte = this.faceSearchRepository.createQueryBuilder().insert().values(embeddingsToAdd).orIgnore();
query.addCommonTableExpression(embeddingCte, 'embeddings');
query.getQuery(); // typeorm mixes up parameters without this
}
await query.execute();

View file

@ -325,7 +325,7 @@ export class PersonService extends BaseService {
if (match && !mlFaceIds.delete(match.id)) {
embeddings.push({ faceId: match.id, embedding });
} else {
} else if (!match) {
const faceId = this.cryptoRepository.randomUUID();
facesToAdd.push({
id: faceId,