mirror of
https://github.com/immich-app/immich.git
synced 2025-02-11 01:18:24 -05:00
fix(server): Thumbnail migration creating unnecessary directories (#4251)
* fix: during migration folders will be created before checking if needed * refactor
This commit is contained in:
parent
85efbc6984
commit
cc70f5f6a0
1 changed files with 18 additions and 12 deletions
|
@ -98,23 +98,29 @@ export class MediaService {
|
||||||
if (!asset) {
|
if (!asset) {
|
||||||
return false;
|
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) {
|
if (asset.resizePath) {
|
||||||
await this.storageRepository.moveFile(asset.resizePath, resizePath);
|
const resizePath = this.ensureThumbnailPath(asset, 'jpeg');
|
||||||
await this.assetRepository.save({ id: asset.id, resizePath });
|
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) {
|
if (asset.webpPath) {
|
||||||
await this.storageRepository.moveFile(asset.webpPath, webpPath);
|
const webpPath = this.ensureThumbnailPath(asset, 'webp');
|
||||||
await this.assetRepository.save({ id: asset.id, webpPath });
|
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) {
|
if (asset.encodedVideoPath) {
|
||||||
await this.storageRepository.moveFile(asset.encodedVideoPath, encodedVideoPath);
|
const encodedVideoPath = this.ensureEncodedVideoPath(asset, 'mp4');
|
||||||
await this.assetRepository.save({ id: asset.id, encodedVideoPath });
|
if (asset.encodedVideoPath !== encodedVideoPath) {
|
||||||
|
await this.storageRepository.moveFile(asset.encodedVideoPath, encodedVideoPath);
|
||||||
|
await this.assetRepository.save({ id: asset.id, encodedVideoPath });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Add table
Reference in a new issue