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:
parent
649897f737
commit
eb7777639d
1 changed files with 13 additions and 8 deletions
|
@ -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(
|
||||
|
|
Loading…
Reference in a new issue