Skip to content

armgit / ente

Public Imported from GitHub
0

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

Start using @/media's version

Manav Rathi317210457832
diff --git a/web/apps/cast/package.json b/web/apps/cast/package.json
index ee318ef619..2437c6c145 100644
--- a/web/apps/cast/package.json
+++ b/web/apps/cast/package.json
@@ -3,11 +3,11 @@
"version": "0.0.0",
"private": true,
"dependencies": {
+ "@/media": "*",
"@/next": "*",
"@ente/accounts": "*",
"@ente/eslint-config": "*",
"@ente/shared": "*",
- "jszip": "3.10.1",
"mime-types": "^2.1.35"
}
}
diff --git a/web/apps/cast/src/utils/file/index.ts b/web/apps/cast/src/utils/file/index.ts
index 4f6311cbdf..8d724feb52 100644
--- a/web/apps/cast/src/utils/file/index.ts
+++ b/web/apps/cast/src/utils/file/index.ts
@@ -1,8 +1,8 @@
+import { decodeLivePhoto } from "@/media/live-photo";
import log from "@/next/log";
import ComlinkCryptoWorker from "@ente/shared/crypto";
import { FILE_TYPE, RAW_FORMATS } from "constants/file";
import CastDownloadManager from "services/castDownloadManager";
-import { decodeLivePhoto } from "services/livePhotoService";
import { getFileType } from "services/typeDetectionService";
import {
EncryptedEnteFile,
@@ -115,6 +115,18 @@ export function isRawFileFromFileName(fileName: string) {
return false;
}
+/**
+ * [Note: File name for local EnteFile objects]
+ *
+ * The title property in a file's metadata is the original file's name. The
+ * metadata of a file cannot be edited. So if later on the file's name is
+ * changed, then the edit is stored in the `editedName` property of the public
+ * metadata of the file.
+ *
+ * This function merges these edits onto the file object that we use locally.
+ * Effectively, post this step, the file's metadata.title can be used in lieu of
+ * its filename.
+ */
export function mergeMetadata(files: EnteFile[]): EnteFile[] {
return files.map((file) => {
if (file.pubMagicMetadata?.data.editedTime) {
@@ -137,7 +149,10 @@ export const getPreviewableImage = async (
await CastDownloadManager.downloadFile(castToken, file),
).blob();
if (file.metadata.fileType === FILE_TYPE.LIVE_PHOTO) {
- const livePhoto = await decodeLivePhoto(file, fileBlob);
+ const livePhoto = await decodeLivePhoto(
+ file.metadata.title,
+ fileBlob,
+ );
fileBlob = new Blob([livePhoto.image]);
}
const fileType = await getFileType(
diff --git a/web/apps/photos/package.json b/web/apps/photos/package.json
index 6ae109af16..4ade92263c 100644
--- a/web/apps/photos/package.json
+++ b/web/apps/photos/package.json
@@ -3,6 +3,7 @@
"version": "0.0.0",
"private": true,
"dependencies": {
+ "@/media": "*",
"@/next": "*",
"@date-io/date-fns": "^2.14.0",
"@ente/accounts": "*",
@@ -25,7 +26,6 @@
"hdbscan": "0.0.1-alpha.5",
"heic-convert": "^2.0.0",
"idb": "^7.1.1",
- "jszip": "3.10.1",
"leaflet": "^1.9.4",
"leaflet-defaulticon-compatibility": "^0.1.1",
"localforage": "^1.9.0",
diff --git a/web/apps/photos/src/types/upload/index.ts b/web/apps/photos/src/types/upload/index.ts
index 0d38f6190f..3deab0ed79 100644
--- a/web/apps/photos/src/types/upload/index.ts
+++ b/web/apps/photos/src/types/upload/index.ts
@@ -24,6 +24,11 @@ export function isDataStream(object: any): object is DataStream {
export type Logger = (message: string) => void;
export interface Metadata {
+ /**
+ * The file name.
+ *
+ * See: [Note: File name for local EnteFile objects]
+ */
title: string;
creationTime: number;
modificationTime: number;
diff --git a/web/apps/photos/src/utils/file/index.ts b/web/apps/photos/src/utils/file/index.ts
index 785921cc91..f954016fb6 100644
--- a/web/apps/photos/src/utils/file/index.ts
+++ b/web/apps/photos/src/utils/file/index.ts
@@ -1,3 +1,4 @@
+import { decodeLivePhoto } from "@/media/live-photo";
import { convertBytesToHumanReadable } from "@/next/file";
import log from "@/next/log";
import type { Electron } from "@/next/types/ipc";
@@ -32,7 +33,6 @@ import {
updateFilePublicMagicMetadata,
} from "services/fileService";
import heicConversionService from "services/heicConversionService";
-import { decodeLivePhoto } from "services/livePhotoService";
import { getFileType } from "services/typeDetectionService";
import { updateFileCreationDateInEXIF } from "services/upload/exifService";
import {
@@ -97,7 +97,10 @@ export async function downloadFile(file: EnteFile) {
await DownloadManager.getFile(file),
).blob();
if (file.metadata.fileType === FILE_TYPE.LIVE_PHOTO) {
- const livePhoto = await decodeLivePhoto(file, fileBlob);
+ const livePhoto = await decodeLivePhoto(
+ file.metadata.title,
+ fileBlob,
+ );
const image = new File([livePhoto.image], livePhoto.imageNameTitle);
const imageType = await getFileType(image);
const tempImageURL = URL.createObjectURL(
@@ -355,7 +358,7 @@ async function getRenderableLivePhotoURL(
fileBlob: Blob,
forceConvert: boolean,
): Promise<LivePhotoSourceURL> {
- const livePhoto = await decodeLivePhoto(file, fileBlob);
+ const livePhoto = await decodeLivePhoto(file.metadata.title, fileBlob);
const getRenderableLivePhotoImageURL = async () => {
try {
@@ -813,7 +816,7 @@ async function downloadFileDesktop(
if (file.metadata.fileType === FILE_TYPE.LIVE_PHOTO) {
const fileBlob = await new Response(updatedStream).blob();
- const livePhoto = await decodeLivePhoto(file, fileBlob);
+ const livePhoto = await decodeLivePhoto(file.metadata.title, fileBlob);
const imageExportName = await safeFileName(
downloadDir,
livePhoto.imageNameTitle,
diff --git a/web/yarn.lock b/web/yarn.lock
index 8461b3855c..61d2cfeae1 100644
--- a/web/yarn.lock
+++ b/web/yarn.lock
@@ -3252,7 +3252,7 @@ jssha@~3.3.1:
object.assign "^4.1.4"
object.values "^1.1.6"
[email protected], jszip@^3.10:
+jszip@^3.10:
version "3.10.1"
resolved "https://registry.yarnpkg.com/jszip/-/jszip-3.10.1.tgz#34aee70eb18ea1faec2f589208a157d1feb091c2"
integrity sha512-xXDvecyTpGLrqFrvkrUSoxxfJI5AH7U8zxxtVclpsUtMCq4JQ290LY8AW5c7Ggnr/Y/oK+bQMbqK2qmtk3pN4g==