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:
parent
9d0f03808c
commit
08d428cbce
2 changed files with 3 additions and 2 deletions
|
@ -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();
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue