Skip to content

High performance self-hosted photo and video management solution.

fix(server): Thumbnail migration creating unnecessary directories (#4251)

Daniel Dietzlercc70f5f6a0a5
diff --git a/server/src/domain/media/media.service.ts b/server/src/domain/media/media.service.ts
index 9e2ae8eb40..f836026de5 100644
--- a/server/src/domain/media/media.service.ts
+++ b/server/src/domain/media/media.service.ts
@@ -98,23 +98,29 @@ export class MediaService {
if (!asset) {
return false;
}
- const resizePath = this.ensureThumbnailPath(asset, 'jpeg');
- const webpPath = this.ensureThumbnailPath(asset, 'webp');
- const encodedVideoPath = this.ensureEncodedVideoPath(asset, 'mp4');
- if (asset.resizePath && asset.resizePath !== resizePath) {
- await this.storageRepository.moveFile(asset.resizePath, resizePath);
- await this.assetRepository.save({ id: asset.id, resizePath });
+ if (asset.resizePath) {
+ const resizePath = this.ensureThumbnailPath(asset, 'jpeg');
+ if (asset.resizePath !== resizePath) {
+ await this.storageRepository.moveFile(asset.resizePath, resizePath);
+ await this.assetRepository.save({ id: asset.id, resizePath });
+ }
}
- if (asset.webpPath && asset.webpPath !== webpPath) {
- await this.storageRepository.moveFile(asset.webpPath, webpPath);
- await this.assetRepository.save({ id: asset.id, webpPath });
+ if (asset.webpPath) {
+ const webpPath = this.ensureThumbnailPath(asset, 'webp');
+ if (asset.webpPath !== webpPath) {
+ await this.storageRepository.moveFile(asset.webpPath, webpPath);
+ await this.assetRepository.save({ id: asset.id, webpPath });
+ }
}
- if (asset.encodedVideoPath && asset.encodedVideoPath !== encodedVideoPath) {
- await this.storageRepository.moveFile(asset.encodedVideoPath, encodedVideoPath);
- await this.assetRepository.save({ id: asset.id, encodedVideoPath });
+ if (asset.encodedVideoPath) {
+ const encodedVideoPath = this.ensureEncodedVideoPath(asset, 'mp4');
+ if (asset.encodedVideoPath !== encodedVideoPath) {
+ await this.storageRepository.moveFile(asset.encodedVideoPath, encodedVideoPath);
+ await this.assetRepository.save({ id: asset.id, encodedVideoPath });
+ }
}
return true;