refactor(server): track thumbnail jobs in job status table (#11908)

refactor: track thumbnail jobs in job status table
This commit is contained in:
Jason Rasmussen
2024-08-19 13:50:00 -04:00
committed by GitHub
parent 8338657eaa
commit d9698884bd
4 changed files with 49 additions and 9 deletions

View File

@@ -178,11 +178,18 @@ export class MediaService {
}
const previewPath = await this.generateThumbnail(asset, AssetPathType.PREVIEW, image.previewFormat);
if (!previewPath) {
return JobStatus.SKIPPED;
}
if (asset.previewPath && asset.previewPath !== previewPath) {
this.logger.debug(`Deleting old preview for asset ${asset.id}`);
await this.storageRepository.unlink(asset.previewPath);
}
await this.assetRepository.update({ id: asset.id, previewPath });
await this.assetRepository.upsertJobStatus({ assetId: asset.id, previewAt: new Date() });
return JobStatus.SUCCESS;
}
@@ -257,11 +264,18 @@ export class MediaService {
}
const thumbnailPath = await this.generateThumbnail(asset, AssetPathType.THUMBNAIL, image.thumbnailFormat);
if (!thumbnailPath) {
return JobStatus.SKIPPED;
}
if (asset.thumbnailPath && asset.thumbnailPath !== thumbnailPath) {
this.logger.debug(`Deleting old thumbnail for asset ${asset.id}`);
await this.storageRepository.unlink(asset.thumbnailPath);
}
await this.assetRepository.update({ id: asset.id, thumbnailPath });
await this.assetRepository.upsertJobStatus({ assetId: asset.id, thumbnailAt: new Date() });
return JobStatus.SUCCESS;
}