π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Preserve edited photo metadata on upload
Anand Baburajan1e9e6b2e6472
diff --git a/web/apps/photos/src/services/upload-manager.ts b/web/apps/photos/src/services/upload-manager.tsindex 22b2231a72..da05315a18 100644--- a/web/apps/photos/src/services/upload-manager.ts+++ b/web/apps/photos/src/services/upload-manager.ts@@ -34,6 +34,7 @@ import type { Collection } from "ente-media/collection";import { type EnteFile } from "ente-media/file";import {fileCreationTime,+ fileLocation,type ParsedMetadata,} from "ente-media/file-metadata";import { FileType } from "ente-media/file-type";@@ -412,20 +413,30 @@ class UploadManager {const timestamp = fileCreationTime(sourceEnteFile);const dateTime = sourceEnteFile.pubMagicMetadata?.data.dateTime;const offset = sourceEnteFile.pubMagicMetadata?.data.offsetTime;+ const location = fileLocation(sourceEnteFile);const creationDate: ParsedMetadata["creationDate"] = dateTime? { timestamp, dateTime, offset }: undefined;- // Fallback to the timestamp if a creationDate could not be constructed.- const creationTime = creationDate ? undefined : timestamp;+ // Canvas exports do not retain the original file's embedded metadata, so+ // preserve the metadata Ente already knows about the source file.+ //+ // Preserve the richer creationDate when available so the edited copy+ // retains the original photo's local capture date/time semantics (and+ // optional offset), not just the raw UTC timestamp.+ const externalParsedMetadata = {+ creationDate,+ creationTime: creationDate ? undefined : timestamp,+ location,+ };const item = {uploadItem: file,pathPrefix: undefined,localID: 1,collectionID: collection.id,- externalParsedMetadata: { creationDate, creationTime },+ externalParsedMetadata,};return this.uploadItems([item], [collection]);@@ -696,6 +707,7 @@ const clusterLivePhotos = async (type ItemAsset = PotentialLivePhotoAsset & {localID: number;isLivePhoto?: boolean;+ externalParsedMetadata?: UploadItemWithCollectionIDAndName["externalParsedMetadata"];};const items: ItemAsset[] = _items.map((item) => ({localID: item.localID,@@ -705,6 +717,7 @@ const clusterLivePhotos = async (collectionID: item.collectionID,uploadItem: item.uploadItem!,pathPrefix: item.pathPrefix,+ externalParsedMetadata: item.externalParsedMetadata,}));items.sort((f, g) => {@@ -727,6 +740,7 @@ const clusterLivePhotos = async (fileName: image.fileName,isLivePhoto: true,pathPrefix: image.pathPrefix,+ externalParsedMetadata: image.externalParsedMetadata,livePhotoAssets: {image: image.uploadItem,video: video.uploadItem,diff --git a/web/packages/gallery/services/upload/index.ts b/web/packages/gallery/services/upload/index.tsindex 1840639c32..4719cf79c3 100644--- a/web/packages/gallery/services/upload/index.ts+++ b/web/packages/gallery/services/upload/index.ts@@ -7,6 +7,7 @@ import type { Collection } from "ente-media/collection";import type { EnteFile } from "ente-media/file";import { nullToUndefined } from "ente-utils/transform";import { z } from "zod";+import type { ExternalParsedMetadata } from "./upload-service";/*** Internal in-memory state shared by the functions in this module.@@ -268,6 +269,7 @@ export interface ClusteredUploadItem {isLivePhoto: boolean;uploadItem?: UploadItem;pathPrefix: UploadPathPrefix | undefined;+ externalParsedMetadata?: ExternalParsedMetadata;// TODO: Tie this to the isLivePhoto flag using a discriminated union.livePhotoAssets?: LivePhotoAssets;}