This commit is contained in:
Devesh Kolte 2026-08-11 20:08:46 +07:00 committed by GitHub
commit f4f0d2b3e1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 15 additions and 6 deletions

View file

@ -130,7 +130,12 @@ export class PersonRepository {
.selectFrom('person')
.selectAll('person')
.$if(!!options.ownerId, (qb) => qb.where('person.ownerId', '=', options.ownerId!))
.$if(options.thumbnailPath !== undefined, (qb) => qb.where('person.thumbnailPath', '=', options.thumbnailPath!))
.$if(options.thumbnailPath !== undefined, (qb) => {
if (options.thumbnailPath === null) {
return qb.where('person.thumbnailPath', 'is', null);
}
return qb.where('person.thumbnailPath', '=', options.thumbnailPath!);
})
.$if(options.faceAssetId === null, (qb) => qb.where('person.faceAssetId', 'is', null))
.$if(!!options.faceAssetId, (qb) => qb.where('person.faceAssetId', '=', options.faceAssetId!))
.$if(options.isHidden !== undefined, (qb) => qb.where('person.isHidden', '=', options.isHidden!))
@ -142,7 +147,7 @@ export class PersonRepository {
return this.db
.selectFrom('person')
.select(['id', 'thumbnailPath'])
.where('thumbnailPath', '!=', sql.lit(''))
.where('thumbnailPath', 'is not', null)
.limit(sql.lit(3))
.execute();
}

View file

@ -187,7 +187,7 @@ export class CliService extends BaseService {
this.userRepository.getFileSamples(),
]);
const paths = Array.from(people, (person) => person.thumbnailPath);
const paths = Array.from(people, (person) => person.thumbnailPath).filter(Boolean) as string[];
for (const user of users) {
paths.push(user.profileImagePath);

View file

@ -96,7 +96,7 @@ export class MediaService extends BaseService {
await queueAll();
const people = this.personRepository.getAll(force ? undefined : { thumbnailPath: '' });
const people = this.personRepository.getAll(force ? undefined : { thumbnailPath: null });
for await (const person of people) {
if (!person.faceAssetId) {

View file

@ -251,8 +251,12 @@ export class PersonService extends BaseService {
}
@Chunked()
private async removeAllPeople(people: { id: string; thumbnailPath: string }[]) {
await Promise.all(people.map((person) => this.storageRepository.unlink(person.thumbnailPath)));
private async removeAllPeople(people: { id: string; thumbnailPath: string | null }[]) {
await Promise.all(
people.map((person) =>
person.thumbnailPath ? this.storageRepository.unlink(person.thumbnailPath) : Promise.resolve(),
),
);
await this.personRepository.delete(people.map((person) => person.id));
this.logger.debug(`Deleted ${people.length} people`);
}