mirror of
https://github.com/immich-app/immich.git
synced 2025-12-21 17:25:35 +03:00
feat(server): normalize extensions in storage template (#16667)
* normalize and lowercase extensions * un const * do not change ext before stripping off old one * braces
This commit is contained in:
@@ -105,7 +105,7 @@ describe(StorageTemplateService.name, () => {
|
||||
it('should migrate single moving picture', async () => {
|
||||
mocks.user.get.mockResolvedValue(userStub.user1);
|
||||
const newMotionPicturePath = `upload/library/${userStub.user1.id}/2022/2022-06-19/${assetStub.livePhotoStillAsset.id}.mp4`;
|
||||
const newStillPicturePath = `upload/library/${userStub.user1.id}/2022/2022-06-19/${assetStub.livePhotoStillAsset.id}.jpeg`;
|
||||
const newStillPicturePath = `upload/library/${userStub.user1.id}/2022/2022-06-19/${assetStub.livePhotoStillAsset.id}.jpg`;
|
||||
|
||||
mocks.asset.getByIds.mockImplementation((ids) => {
|
||||
const assets = [assetStub.livePhotoStillAsset, assetStub.livePhotoMotionAsset];
|
||||
|
||||
@@ -226,10 +226,37 @@ export class StorageTemplateService extends BaseService {
|
||||
|
||||
try {
|
||||
const source = asset.originalPath;
|
||||
const extension = path.extname(source).split('.').pop() as string;
|
||||
let extension = path.extname(source).split('.').pop() as string;
|
||||
const sanitized = sanitize(path.basename(filename, `.${extension}`));
|
||||
extension = extension?.toLowerCase();
|
||||
const rootPath = StorageCore.getLibraryFolder({ id: asset.ownerId, storageLabel });
|
||||
|
||||
switch (extension) {
|
||||
case 'jpeg':
|
||||
case 'jpe': {
|
||||
extension = 'jpg';
|
||||
break;
|
||||
}
|
||||
case 'tif': {
|
||||
extension = 'tiff';
|
||||
break;
|
||||
}
|
||||
case '3gpp': {
|
||||
extension = '3gp';
|
||||
break;
|
||||
}
|
||||
case 'mpeg':
|
||||
case 'mpe': {
|
||||
extension = 'mpg';
|
||||
break;
|
||||
}
|
||||
case 'm2ts':
|
||||
case 'm2t': {
|
||||
extension = 'mts';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
let albumName = null;
|
||||
if (this.template.needsAlbum) {
|
||||
const albums = await this.albumRepository.getByAssetId(asset.ownerId, asset.id);
|
||||
|
||||
Reference in New Issue
Block a user