Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

LivePhotoCluster: Handle _HVEC suffix

Neeraj Guptad6b7d260f067
diff --git a/apps/photos/src/services/upload/livePhotoService.ts b/apps/photos/src/services/upload/livePhotoService.ts
index fd345a345e..6e0f1b12c1 100644
--- a/apps/photos/src/services/upload/livePhotoService.ts
+++ b/apps/photos/src/services/upload/livePhotoService.ts
@@ -30,7 +30,9 @@ interface LivePhotoIdentifier {
}
const UNDERSCORE_THREE = '_3';
-
+// Note: The icloud-photos-downloader library appends _HVEC to the end of the filename in case of live photos
+// https://github.com/icloud-photos-downloader/icloud_photos_downloader
+const UNDERSCORE_HEVC = '_HVEC';
const UNDERSCORE = '_';
export async function getLivePhotoFileType(
@@ -223,10 +225,10 @@ function areFilesLivePhotoAssets(
firstFileIdentifier.fileType !== secondFileIdentifier.fileType &&
isImageOrVideo(firstFileIdentifier.fileType) &&
isImageOrVideo(secondFileIdentifier.fileType) &&
- removeUnderscoreThreeSuffix(
+ removePotentailLivePhotoSuffix(
splitFilenameAndExtension(firstFileIdentifier.name)[0]
) ===
- removeUnderscoreThreeSuffix(
+ removePotentailLivePhotoSuffix(
splitFilenameAndExtension(secondFileIdentifier.name)[0]
)
) {
@@ -254,10 +256,11 @@ function areFilesLivePhotoAssets(
return false;
}
-function removeUnderscoreThreeSuffix(filename: string) {
+function removePotentailLivePhotoSuffix(filename: string) {
if (filename.endsWith(UNDERSCORE_THREE)) {
return filename.slice(0, filename.lastIndexOf(UNDERSCORE));
- } else {
- return filename;
+ } else if (filename.toLowerCase().endsWith(UNDERSCORE_HEVC)) {
+ return filename.slice(0, filename.lastIndexOf(UNDERSCORE_HEVC));
}
+ return filename;
}