mirror of
https://github.com/immich-app/immich
synced 2026-08-15 13:03:57 +00:00
Merge 5a712b9d5a into 9773d72428
This commit is contained in:
commit
f4f0d2b3e1
4 changed files with 15 additions and 6 deletions
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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`);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue