Skip to content

armgit / ente

Public Imported from GitHub
0

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

Parallel

Manav Rathi5dd21b2b38a8
diff --git a/web/apps/photos/src/services/upload/metadataService.ts b/web/apps/photos/src/services/upload/metadataService.ts
index 5a8c4e1f5d..a08b3a7a17 100644
--- a/web/apps/photos/src/services/upload/metadataService.ts
+++ b/web/apps/photos/src/services/upload/metadataService.ts
@@ -1,5 +1,5 @@
import { encodeLivePhoto } from "@/media/live-photo";
-import { getFileNameSize } from "@/next/file";
+import { basename, getFileNameSize } from "@/next/file";
import log from "@/next/log";
import { DedicatedCryptoWorker } from "@ente/shared/crypto/internal/crypto.worker";
import { CustomError } from "@ente/shared/error";
@@ -32,6 +32,7 @@ import {
ParsedExtractedMetadata,
ParsedMetadataJSON,
ParsedMetadataJSONMap,
+ type LivePhotoAssets2,
} from "types/upload";
import { getFileTypeFromExtensionForLivePhotoClustering } from "utils/file/livePhoto";
import { getUint8ArrayView } from "../readerService";
@@ -374,9 +375,8 @@ export function getLivePhotoSize(livePhotoAssets: LivePhotoAssets) {
return livePhotoAssets.image.size + livePhotoAssets.video.size;
}
-export function getLivePhotoName(livePhotoAssets: LivePhotoAssets) {
- return livePhotoAssets.image.name;
-}
+export const getLivePhotoName = ({ image }: LivePhotoAssets2) =>
+ typeof image == "string" ? basename(image) : image.name;
export async function readLivePhoto(
fileTypeInfo: FileTypeInfo,
diff --git a/web/apps/photos/src/services/upload/uploadService.ts b/web/apps/photos/src/services/upload/uploadService.ts
index abcf495916..493bcd4251 100644
--- a/web/apps/photos/src/services/upload/uploadService.ts
+++ b/web/apps/photos/src/services/upload/uploadService.ts
@@ -1,4 +1,8 @@
-import { convertBytesToHumanReadable, getFileNameSize } from "@/next/file";
+import {
+ basename,
+ convertBytesToHumanReadable,
+ getFileNameSize,
+} from "@/next/file";
import log from "@/next/log";
import { DedicatedCryptoWorker } from "@ente/shared/crypto/internal/crypto.worker";
import {
@@ -41,6 +45,7 @@ import {
UploadFile,
UploadURL,
isDataStream,
+ type UploadAsset2,
} from "types/upload";
import {
getNonEmptyMagicMetadataProps,
@@ -133,6 +138,12 @@ class UploadService {
: getFilename(file);
}
+ getAssetName2({ isLivePhoto, file, livePhotoAssets }: UploadAsset2) {
+ return isLivePhoto
+ ? getLivePhotoName(livePhotoAssets)
+ : getFilename(file);
+ }
+
getAssetFileType({ isLivePhoto, file, livePhotoAssets }: UploadAsset) {
return isLivePhoto
? getLivePhotoFileType(livePhotoAssets)
@@ -361,9 +372,8 @@ function getFileSize(file: File | ElectronFile) {
return file.size;
}
-function getFilename(file: File | ElectronFile) {
- return file.name;
-}
+const getFilename = (file: File | ElectronFile | string) =>
+ typeof file == "string" ? basename(file) : file.name;
async function readFile(
fileTypeInfo: FileTypeInfo,