1
0
mirror of https://github.com/immich-app/immich.git synced 2025-06-24 04:46:50 +02:00

fix(web+mobile): consistent filename handling (#2534)

This commit is contained in:
Michel Heusschen
2023-05-28 03:53:29 +02:00
committed by GitHub
parent 6c6c5ef651
commit 7f0ad8e2d2
5 changed files with 78 additions and 25 deletions

View File

@ -24,7 +24,7 @@
import VideoViewer from './video-viewer.svelte';
import { assetStore } from '$lib/stores/assets.store';
import { addAssetsToAlbum } from '$lib/utils/asset-utils';
import { addAssetsToAlbum, getFilenameExtension } from '$lib/utils/asset-utils';
import { browser } from '$app/environment';
export let asset: AssetResponseDto;
@ -125,24 +125,10 @@
downloadFile(asset.id, false, publicSharedKey);
};
/**
* Get the filename of the asset based on the user defined template
*/
const getTemplateFilename = () => {
const filenameWithExtension = asset.originalPath.split('/').pop() as string;
const filenameWithoutExtension = filenameWithExtension.split('.')[0];
return {
filenameWithExtension,
filenameWithoutExtension
};
};
const downloadFile = async (assetId: string, isLivePhoto: boolean, key: string) => {
try {
const { filenameWithoutExtension } = getTemplateFilename();
const imageExtension = isLivePhoto ? 'mov' : asset.originalPath.split('.')[1];
const imageFileName = filenameWithoutExtension + '.' + imageExtension;
const imageExtension = isLivePhoto ? 'mov' : getFilenameExtension(asset.originalPath);
const imageFileName = asset.originalFileName + '.' + imageExtension;
// If assets is already download -> return;
if ($downloadAssets[imageFileName]) {