Skip to content

High performance self-hosted photo and video management solution.

fix(web): prevent Safari from overwriting live photo image with video (#26898)

Saurav Sharmae2d26ebdea86
diff --git a/web/src/lib/services/asset.service.spec.ts b/web/src/lib/services/asset.service.spec.ts
index 170f5d2f23..b63df86479 100644
--- a/web/src/lib/services/asset.service.spec.ts
+++ b/web/src/lib/services/asset.service.spec.ts
@@ -78,7 +78,7 @@ describe('AssetService', () => {
const asset = assetFactory.build({ originalFileName: 'asset.heic', livePhotoVideoId: '1' });
await handleDownloadAsset(asset, { edited: false });
expect($t).toHaveBeenNthCalledWith(1, 'downloading_asset_filename', { values: { filename: 'asset.heic' } });
- expect($t).toHaveBeenNthCalledWith(2, 'downloading_asset_filename', { values: { filename: 'asset.mov' } });
+ expect($t).toHaveBeenNthCalledWith(2, 'downloading_asset_filename', { values: { filename: 'asset-motion.mov' } });
expect(toastManager.primary).toHaveBeenCalledWith('formatter');
});
});
diff --git a/web/src/lib/services/asset.service.ts b/web/src/lib/services/asset.service.ts
index baade8facd..bc16b65577 100644
--- a/web/src/lib/services/asset.service.ts
+++ b/web/src/lib/services/asset.service.ts
@@ -319,8 +319,14 @@ export const handleDownloadAsset = async (asset: AssetResponseDto, { edited }: {
if (asset.livePhotoVideoId) {
const motionAsset = await getAssetInfo({ ...authManager.params, id: asset.livePhotoVideoId });
if (!isAndroidMotionVideo(motionAsset) || get(preferences)?.download.includeEmbeddedVideos) {
+ const motionFilename = motionAsset.originalFileName;
+ const lastDotIndex = motionFilename.lastIndexOf('.');
+ const motionDownloadFilename =
+ lastDotIndex > 0
+ ? `${motionFilename.slice(0, lastDotIndex)}-motion${motionFilename.slice(lastDotIndex)}`
+ : `${motionFilename}-motion`;
assets.push({
- filename: motionAsset.originalFileName,
+ filename: motionDownloadFilename,
id: asset.livePhotoVideoId,
cacheKey: motionAsset.thumbhash,
});