1
0
mirror of https://github.com/immich-app/immich.git synced 2024-11-28 09:33:27 +02:00

fix(server): get assetFiles when retrieving assets WithoutProperty.THUMBNAIL (#12225)

This commit is contained in:
PyKen 2024-09-02 22:31:02 +09:00 committed by GitHub
parent 39141d3f1c
commit 438344fc8f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 1 deletions

View File

@ -0,0 +1,21 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
export class UpsertMissingAssetJobStatus1725258039306 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`INSERT INTO "asset_job_status" ("assetId", "facesRecognizedAt", "metadataExtractedAt", "duplicatesDetectedAt", "previewAt", "thumbnailAt") SELECT "assetId", NULL, NULL, NULL, NULL, NULL FROM "asset_files" f WHERE "f"."path" IS NOT NULL ON CONFLICT DO NOTHING`,
);
await queryRunner.query(
`UPDATE "asset_job_status" SET "previewAt" = NOW() FROM "asset_files" f WHERE "previewAt" IS NULL AND "asset_job_status"."assetId" = "f"."assetId" AND "f"."type" = 'preview' AND "f"."path" IS NOT NULL`,
);
await queryRunner.query(
`UPDATE "asset_job_status" SET "thumbnailAt" = NOW() FROM "asset_files" f WHERE "thumbnailAt" IS NULL AND "asset_job_status"."assetId" = "f"."assetId" AND "f"."type" = 'thumbnail' AND "f"."path" IS NOT NULL`,
);
}
public async down(): Promise<void> {
// do nothing
}
}

View File

@ -395,7 +395,7 @@ export class AssetRepository implements IAssetRepository {
switch (property) { switch (property) {
case WithoutProperty.THUMBNAIL: { case WithoutProperty.THUMBNAIL: {
relations = { jobStatus: true }; relations = { jobStatus: true, files: true };
where = [ where = [
{ jobStatus: { previewAt: IsNull() }, isVisible: true }, { jobStatus: { previewAt: IsNull() }, isVisible: true },
{ jobStatus: { thumbnailAt: IsNull() }, isVisible: true }, { jobStatus: { thumbnailAt: IsNull() }, isVisible: true },