π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Use in fixer
Manav Rathifead530786a5
diff --git a/web/apps/photos/src/components/FixCreationTime.tsx b/web/apps/photos/src/components/FixCreationTime.tsxindex 836da7924a..9018a48022 100644--- a/web/apps/photos/src/components/FixCreationTime.tsx+++ b/web/apps/photos/src/components/FixCreationTime.tsx@@ -1,12 +1,19 @@import log from "@/base/log";-import type { ParsedMetadataDate } from "@/media/file-metadata";+import {+ decryptPublicMagicMetadata,+ getUICreationDate,+ updateRemotePublicMagicMetadata,+ type ParsedMetadataDate,+} from "@/media/file-metadata";import { FileType } from "@/media/file-type";import { PhotoDateTimePicker } from "@/new/photos/components/PhotoDateTimePicker";import downloadManager from "@/new/photos/services/download";import { extractExifDates } from "@/new/photos/services/exif";import { EnteFile } from "@/new/photos/types/file";import { fileLogID } from "@/new/photos/utils/file";+import { ensure } from "@/utils/ensure";import DialogBox from "@ente/shared/components/DialogBox/";+import ComlinkCryptoWorker from "@ente/shared/crypto";import {Button,FormControl,@@ -21,10 +28,6 @@ import { useFormik } from "formik";import { t } from "i18next";import { GalleryContext } from "pages/gallery";import React, { useContext, useEffect, useState } from "react";-import {- changeFileCreationTime,- updateExistingFilePubMetadata,-} from "utils/file";/** The current state of the fixing process. */type Status = "running" | "completed" | "completed-with-errors";@@ -277,7 +280,7 @@ type SetProgressTracker = React.Dispatch<const updateFiles = async (enteFiles: EnteFile[],fixOption: FixOption,- customDate: ParsedMetadataDate,+ customDate: ParsedMetadataDate | undefined,setProgressTracker: SetProgressTracker,) => {setProgressTracker({ current: 0, total: enteFiles.length });@@ -312,25 +315,29 @@ const updateFiles = async (* {@link fixOption} is provided, but the given underlying image for the given* {@link enteFile} does not have a corresponding Exif (or related) value, then* that file is skipped.- *- * Note that metadata associated with an {@link EnteFile} is immutable, and we- * instead modify the mutable metadata section associated with the file. See- * [Note: Metadatum] for more details.*/-export const updateEnteFileDate = async (+const updateEnteFileDate = async (enteFile: EnteFile,fixOption: FixOption,- customDate: ParsedMetadataDate,+ customDate: ParsedMetadataDate | undefined,) => {let newDate: ParsedMetadataDate | undefined;- if (fixOption === "custom") {- newDate = customDate;++ if (fixOption == "custom") {+ newDate = {+ dateTime: ensure(customDate).dateTime,+ // See [Note: Don't modify offsetTime when editing date via picker]+ // for why we don't also set the offset here.+ offset: undefined,+ timestamp: ensure(customDate).timestamp,+ };} else if (enteFile.metadata.fileType == FileType.image) {const stream = await downloadManager.getFile(enteFile);const blob = await new Response(stream).blob();const file = new File([blob], enteFile.metadata.title);const { DateTimeOriginal, DateTimeDigitized, MetadataDate, DateTime } =await extractExifDates(file);+switch (fixOption) {case "date-time-original":newDate = DateTimeOriginal ?? DateTime;@@ -344,11 +351,27 @@ export const updateEnteFileDate = async (}}- if (newDate && newDate.timestamp !== enteFile.metadata.creationTime) {- const updatedFile = await changeFileCreationTime(+ if (!newDate) return;++ const cryptoWorker = await ComlinkCryptoWorker.getInstance();++ const existingUIDate = getUICreationDate(+ enteFile,+ await decryptPublicMagicMetadata(enteFile,- newDate.timestamp,- );- updateExistingFilePubMetadata(enteFile, updatedFile);- }+ cryptoWorker.decryptMetadata,+ ),+ );+ if (newDate.timestamp == existingUIDate.getTime()) return;++ await updateRemotePublicMagicMetadata(+ enteFile,+ {+ dateTime: newDate.dateTime,+ offsetTime: newDate.offset,+ editedTime: newDate.timestamp,+ },+ cryptoWorker.encryptMetadata,+ cryptoWorker.decryptMetadata,+ );};diff --git a/web/apps/photos/src/components/PhotoViewer/FileInfo/index.tsx b/web/apps/photos/src/components/PhotoViewer/FileInfo/index.tsxindex c947c577f2..25ce1d61b1 100644--- a/web/apps/photos/src/components/PhotoViewer/FileInfo/index.tsx+++ b/web/apps/photos/src/components/PhotoViewer/FileInfo/index.tsx@@ -380,6 +380,8 @@ export const CreationTime: React.FC<CreationTimeProps> = ({try {setLoading(true);if (isInEditMode && enteFile) {+ // [Note: Don't modify offsetTime when editing date via picker]+ //// Use the updated date time (both in its canonical dateTime// form, and also as the legacy timestamp). But don't use the// offset. The offset here will be the offset of the computer