diff --git a/web/apps/photos/src/services/upload/uploadManager.ts b/web/apps/photos/src/services/upload/uploadManager.ts index 065414158..ff75fa462 100644 --- a/web/apps/photos/src/services/upload/uploadManager.ts +++ b/web/apps/photos/src/services/upload/uploadManager.ts @@ -543,11 +543,11 @@ class UploadManager { await wait(0); const { fileUploadResult, uploadedFile } = await uploader( - worker, - this.existingFiles, fileWithCollection, - this.parsedMetadataJSONMap, this.uploaderName, + this.existingFiles, + this.parsedMetadataJSONMap, + worker, this.isCFUploadProxyDisabled, () => { this.abortIfCancelled(); diff --git a/web/apps/photos/src/services/upload/uploadService.ts b/web/apps/photos/src/services/upload/uploadService.ts index fc9e02a0b..d2f7fbe7b 100644 --- a/web/apps/photos/src/services/upload/uploadService.ts +++ b/web/apps/photos/src/services/upload/uploadService.ts @@ -170,11 +170,11 @@ interface UploadResponse { } export const uploader = async ( - worker: Remote, - existingFiles: EnteFile[], fileWithCollection: FileWithCollection2, - parsedMetadataJSONMap: Map, uploaderName: string, + existingFiles: EnteFile[], + parsedMetadataJSONMap: Map, + worker: Remote, isCFUploadProxyDisabled: boolean, abortIfCancelled: () => void, makeProgessTracker: MakeProgressTracker, @@ -185,18 +185,19 @@ export const uploader = async ( try { /* - * We read the file three times: + * We read the file four times: * 1. To determine its MIME type (only needs first few KBs). - * 2. To calculate its hash. - * 3. To encrypt it. + * 2. To extract its metadata. + * 3. To calculate its hash. + * 4. To encrypt it. * - * When we already have a File object the multiple reads are fine. When - * we're in the context of our desktop app and have a path, it might be - * possible to optimize this further by using `ReadableStream.tee` to - * perform these three steps simultaneously. However, that'll require - * restructuring the code so that these steps run in some parallel - * manner (tee will not work for strictly sequential reads of large - * streams). + * When we already have a File object the multiple reads are fine. + * + * When we're in the context of our desktop app and have a path, it + * might be possible to optimize further by using `ReadableStream.tee` + * to perform these steps simultaneously. However, that'll require + * restructuring the code so that these steps run in a parallel manner + * (tee will not work for strictly sequential reads of large streams). */ const { fileTypeInfo, fileSize } = @@ -209,11 +210,11 @@ export const uploader = async ( abortIfCancelled(); const { metadata, publicMagicMetadata } = await extractAssetMetadata( - worker, - parsedMetadataJSONMap, uploadAsset, - collection.id, fileTypeInfo, + collection.id, + parsedMetadataJSONMap, + worker, ); const matches = existingFiles.filter((file) => @@ -499,12 +500,16 @@ interface ExtractMetadataResult { publicMagicMetadata: FilePublicMagicMetadataProps; } +/** + * Compute the hash, extract EXIF or other metadata, and merge in data from the + * {@link parsedMetadataJSONMap} for the assets. Return the resultant metadatum. + */ const extractAssetMetadata = async ( - worker: Remote, - parsedMetadataJSONMap: Map, { isLivePhoto, file, livePhotoAssets }: UploadAsset2, - collectionID: number, fileTypeInfo: FileTypeInfo, + collectionID: number, + parsedMetadataJSONMap: Map, + worker: Remote, ): Promise => { return isLivePhoto ? await extractLivePhotoMetadata( diff --git a/web/apps/photos/src/types/upload/index.ts b/web/apps/photos/src/types/upload/index.ts index 2111617bd..9b2e37a9b 100644 --- a/web/apps/photos/src/types/upload/index.ts +++ b/web/apps/photos/src/types/upload/index.ts @@ -25,6 +25,7 @@ export interface Metadata { modificationTime: number; latitude: number; longitude: number; + /** The "Ente" file type. */ fileType: FILE_TYPE; hasStaticThumbnail?: boolean; hash?: string;