Skip to content

armgit / ente

Public Imported from GitHub
0

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

Move

Manav Rathifeb59b00d2b9
diff --git a/web/apps/photos/src/services/upload/metadataService.ts b/web/apps/photos/src/services/upload/metadataService.ts
index 1e386b2d56..ad391eb456 100644
--- a/web/apps/photos/src/services/upload/metadataService.ts
+++ b/web/apps/photos/src/services/upload/metadataService.ts
@@ -13,11 +13,9 @@ import { FILE_TYPE } from "constants/file";
import { FILE_READER_CHUNK_SIZE, NULL_LOCATION } from "constants/upload";
import * as ffmpegService from "services/ffmpeg";
import { getElectronFileStream, getFileStream } from "services/readerService";
-import { getFileType } from "services/typeDetectionService";
import { FilePublicMagicMetadataProps } from "types/file";
import {
FileTypeInfo,
- LivePhotoAssets,
Metadata,
ParsedExtractedMetadata,
type DataStream,
@@ -95,7 +93,7 @@ export async function extractMetadata(
return { metadata, publicMagicMetadata };
}
-export async function getImageMetadata(
+async function getImageMetadata(
receivedFile: File | ElectronFile,
fileTypeInfo: FileTypeInfo,
): Promise<ParsedExtractedMetadata> {
@@ -129,7 +127,7 @@ export async function getImageMetadata(
}
// tries to extract date from file name if available else returns null
-export function extractDateFromFileName(filename: string): number {
+function extractDateFromFileName(filename: string): number {
try {
filename = filename.trim();
let parsedDate: Date;
@@ -184,19 +182,6 @@ async function getVideoMetadata(file: File | ElectronFile) {
return videoMetadata;
}
-export async function getLivePhotoFileType(
- livePhotoAssets: LivePhotoAssets,
-): Promise<FileTypeInfo> {
- const imageFileTypeInfo = await getFileType(livePhotoAssets.image);
- const videoFileTypeInfo = await getFileType(livePhotoAssets.video);
- return {
- fileType: FILE_TYPE.LIVE_PHOTO,
- exactType: `${imageFileTypeInfo.exactType}+${videoFileTypeInfo.exactType}`,
- imageType: imageFileTypeInfo.exactType,
- videoType: videoFileTypeInfo.exactType,
- };
-}
-
export const extractAssetMetadata = async (
worker: Remote<DedicatedCryptoWorker>,
parsedMetadataJSONMap: Map<string, ParsedMetadataJSON>,
@@ -331,7 +316,3 @@ async function getFileHash(
log.info(`file hashing failed ${getFileNameSize(file)} ,${e.message} `);
}
}
-
-export function getLivePhotoSize(livePhotoAssets: LivePhotoAssets) {
- return livePhotoAssets.image.size + livePhotoAssets.video.size;
-}
diff --git a/web/apps/photos/src/services/upload/uploadService.ts b/web/apps/photos/src/services/upload/uploadService.ts
index 3d496718dd..baa57c7e6c 100644
--- a/web/apps/photos/src/services/upload/uploadService.ts
+++ b/web/apps/photos/src/services/upload/uploadService.ts
@@ -37,6 +37,7 @@ import {
isDataStream,
type DataStream,
type FileWithCollection2,
+ type LivePhotoAssets,
type LivePhotoAssets2,
type Metadata,
type UploadAsset2,
@@ -50,11 +51,7 @@ import { hasFileHash } from "utils/upload";
import * as convert from "xml-js";
import { getFileStream } from "../readerService";
import { getFileType } from "../typeDetectionService";
-import {
- extractAssetMetadata,
- getLivePhotoFileType,
- getLivePhotoSize,
-} from "./metadataService";
+import { extractAssetMetadata, getLivePhotoFileType } from "./metadataService";
import publicUploadHttpClient from "./publicUploadHttpClient";
import type { ParsedMetadataJSON } from "./takeout";
import {
@@ -330,6 +327,10 @@ const getAssetSize = ({ isLivePhoto, file, livePhotoAssets }: UploadAsset) => {
return isLivePhoto ? getLivePhotoSize(livePhotoAssets) : getFileSize(file);
};
+const getLivePhotoSize = (livePhotoAssets: LivePhotoAssets) => {
+ return livePhotoAssets.image.size + livePhotoAssets.video.size;
+};
+
const getAssetFileType = ({
isLivePhoto,
file,
@@ -340,6 +341,19 @@ const getAssetFileType = ({
: getFileType(file);
};
+const getLivePhotoFileType = async (
+ livePhotoAssets: LivePhotoAssets,
+): Promise<FileTypeInfo> => {
+ const imageFileTypeInfo = await getFileType(livePhotoAssets.image);
+ const videoFileTypeInfo = await getFileType(livePhotoAssets.video);
+ return {
+ fileType: FILE_TYPE.LIVE_PHOTO,
+ exactType: `${imageFileTypeInfo.exactType}+${videoFileTypeInfo.exactType}`,
+ imageType: imageFileTypeInfo.exactType,
+ videoType: videoFileTypeInfo.exactType,
+ };
+};
+
const readAsset = async (
fileTypeInfo: FileTypeInfo,
{ isLivePhoto, file, livePhotoAssets }: UploadAsset2,