To point of use

This commit is contained in:
Manav Rathi
2024-04-20 17:46:35 +05:30
parent 5710846125
commit 19103f4961
2 changed files with 31 additions and 31 deletions

View File

@@ -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[] = [];

View File

@@ -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<DedicatedCryptoWorker>,
parsedMetadataJSONMap: ParsedMetadataJSONMap,