1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2025-01-16 00:36:47 +01:00

fix(server): clean face tables after delete (#12375)

clean face tables after delete
This commit is contained in:
Mert 2024-09-05 19:09:19 -04:00 committed by GitHub
parent 649897f737
commit eb7777639d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -6,6 +6,7 @@ import { AssetFaceEntity } from 'src/entities/asset-face.entity';
import { AssetJobStatusEntity } from 'src/entities/asset-job-status.entity';
import { AssetEntity } from 'src/entities/asset.entity';
import { PersonEntity } from 'src/entities/person.entity';
import { SourceType } from 'src/enum';
import {
AssetFaceId,
DeleteAllFacesOptions,
@ -53,16 +54,20 @@ export class PersonRepository implements IPersonRepository {
}
async deleteAllFaces({ sourceType }: DeleteAllFacesOptions): Promise<void> {
if (sourceType) {
await this.assetFaceRepository
.createQueryBuilder('asset_faces')
.delete()
.andWhere('sourceType = :sourceType', { sourceType })
.execute();
return;
if (!sourceType) {
return this.assetFaceRepository.query('TRUNCATE TABLE asset_faces CASCADE');
}
await this.assetFaceRepository.query('TRUNCATE TABLE asset_faces CASCADE');
await this.assetFaceRepository
.createQueryBuilder('asset_faces')
.delete()
.andWhere('sourceType = :sourceType', { sourceType })
.execute();
await this.assetFaceRepository.query('VACUUM ANALYZE asset_faces, face_search');
if (sourceType === SourceType.MACHINE_LEARNING) {
await this.assetFaceRepository.query('REINDEX INDEX face_index');
}
}
getAllFaces(