From 19103f49610aed1c41caebdbc84badc7b481e8fe Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Sat, 20 Apr 2024 17:46:35 +0530 Subject: [PATCH] To point of use --- .../src/services/upload/metadataService.ts | 31 ------------------- .../src/services/upload/uploadService.ts | 31 +++++++++++++++++++ 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/web/apps/photos/src/services/upload/metadataService.ts b/web/apps/photos/src/services/upload/metadataService.ts index 8edda61fd3..13acf3d650 100644 --- a/web/apps/photos/src/services/upload/metadataService.ts +++ b/web/apps/photos/src/services/upload/metadataService.ts @@ -1,4 +1,3 @@ -import { encodeLivePhoto } from "@/media/live-photo"; import { ensureElectron } from "@/next/electron"; import { basename, getFileNameSize } from "@/next/file"; import log from "@/next/log"; @@ -31,9 +30,7 @@ import { type LivePhotoAssets2, } from "types/upload"; import { getFileTypeFromExtensionForLivePhotoClustering } from "utils/file/livePhoto"; -import { getUint8ArrayView } from "../readerService"; import { getEXIFLocation, getEXIFTime, getParsedExifData } from "./exifService"; -import { generateThumbnail } from "./thumbnailService"; import uploadCancelService from "./uploadCancelService"; import { extractFileMetadata, getFileName } from "./uploadService"; @@ -393,34 +390,6 @@ export function getLivePhotoSize(livePhotoAssets: LivePhotoAssets) { export const getLivePhotoName = ({ image }: LivePhotoAssets2) => typeof image == "string" ? basename(image) : image.name; -export async function readLivePhoto( - fileTypeInfo: FileTypeInfo, - livePhotoAssets: LivePhotoAssets, -) { - const { thumbnail, hasStaticThumbnail } = await generateThumbnail( - livePhotoAssets.image, - { - exactType: fileTypeInfo.imageType, - fileType: FILE_TYPE.IMAGE, - }, - ); - - const imageData = await getUint8ArrayView(livePhotoAssets.image); - - const videoData = await getUint8ArrayView(livePhotoAssets.video); - - return { - filedata: await encodeLivePhoto({ - imageFileName: livePhotoAssets.image.name, - imageData, - videoFileName: livePhotoAssets.video.name, - videoData, - }), - thumbnail, - hasStaticThumbnail, - }; -} - export async function clusterLivePhotoFiles(mediaFiles: FileWithCollection2[]) { try { const analysedMediaFiles: FileWithCollection2[] = []; diff --git a/web/apps/photos/src/services/upload/uploadService.ts b/web/apps/photos/src/services/upload/uploadService.ts index ae4b827634..123b75d323 100644 --- a/web/apps/photos/src/services/upload/uploadService.ts +++ b/web/apps/photos/src/services/upload/uploadService.ts @@ -1,3 +1,4 @@ +import { encodeLivePhoto } from "@/media/live-photo"; import { basename, convertBytesToHumanReadable, @@ -12,6 +13,7 @@ import { import { CustomError, handleUploadError } from "@ente/shared/error"; import { wait } from "@ente/shared/utils"; import { Remote } from "comlink"; +import { FILE_TYPE } from "constants/file"; import { FILE_READER_CHUNK_SIZE, MULTIPART_PART_SIZE, @@ -44,6 +46,7 @@ import { UploadURL, isDataStream, type FileWithCollection2, + type LivePhotoAssets, type UploadAsset2, } from "types/upload"; import { @@ -397,6 +400,34 @@ async function readFile( }; } +async function readLivePhoto( + fileTypeInfo: FileTypeInfo, + livePhotoAssets: LivePhotoAssets, +) { + const { thumbnail, hasStaticThumbnail } = await generateThumbnail( + livePhotoAssets.image, + { + exactType: fileTypeInfo.imageType, + fileType: FILE_TYPE.IMAGE, + }, + ); + + const imageData = await getUint8ArrayView(livePhotoAssets.image); + + const videoData = await getUint8ArrayView(livePhotoAssets.video); + + return { + filedata: await encodeLivePhoto({ + imageFileName: livePhotoAssets.image.name, + imageData, + videoFileName: livePhotoAssets.video.name, + videoData, + }), + thumbnail, + hasStaticThumbnail, + }; +} + export async function extractFileMetadata( worker: Remote, parsedMetadataJSONMap: ParsedMetadataJSONMap,