fix(server): untracked thumbnail and preview images (#9126)

* delete old thumbnails

* add tests

* revert invisible asset handling
This commit is contained in:
Mert
2024-04-27 18:43:05 -04:00
committed by GitHub
parent 19aa97da02
commit 2648032163
3 changed files with 48 additions and 0 deletions

View File

@@ -185,6 +185,10 @@ export class MediaService {
}
const previewPath = await this.generateThumbnail(asset, AssetPathType.PREVIEW, image.previewFormat);
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 });
return JobStatus.SUCCESS;
}
@@ -253,6 +257,10 @@ export class MediaService {
}
const thumbnailPath = await this.generateThumbnail(asset, AssetPathType.THUMBNAIL, image.thumbnailFormat);
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 });
return JobStatus.SUCCESS;
}