mirror of
https://github.com/immich-app/immich.git
synced 2025-01-28 06:32:44 +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 { AssetJobStatusEntity } from 'src/entities/asset-job-status.entity';
|
||||||
import { AssetEntity } from 'src/entities/asset.entity';
|
import { AssetEntity } from 'src/entities/asset.entity';
|
||||||
import { PersonEntity } from 'src/entities/person.entity';
|
import { PersonEntity } from 'src/entities/person.entity';
|
||||||
|
import { SourceType } from 'src/enum';
|
||||||
import {
|
import {
|
||||||
AssetFaceId,
|
AssetFaceId,
|
||||||
DeleteAllFacesOptions,
|
DeleteAllFacesOptions,
|
||||||
|
@ -53,16 +54,20 @@ export class PersonRepository implements IPersonRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteAllFaces({ sourceType }: DeleteAllFacesOptions): Promise<void> {
|
async deleteAllFaces({ sourceType }: DeleteAllFacesOptions): Promise<void> {
|
||||||
if (sourceType) {
|
if (!sourceType) {
|
||||||
await this.assetFaceRepository
|
return this.assetFaceRepository.query('TRUNCATE TABLE asset_faces CASCADE');
|
||||||
.createQueryBuilder('asset_faces')
|
|
||||||
.delete()
|
|
||||||
.andWhere('sourceType = :sourceType', { sourceType })
|
|
||||||
.execute();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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(
|
getAllFaces(
|
||||||
|
|
Loading…
Reference in a new issue