Skip to content

armgit / ente

Public Imported from GitHub
0

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

Images

Manav Rathic8542211b4db
diff --git a/web/apps/photos/src/services/upload/uploadService.ts b/web/apps/photos/src/services/upload/uploadService.ts
index b5a3361576..43f787ac9f 100644
--- a/web/apps/photos/src/services/upload/uploadService.ts
+++ b/web/apps/photos/src/services/upload/uploadService.ts
@@ -656,13 +656,22 @@ async function tryExtractImageMetadata(
fileTypeInfo: FileTypeInfo,
lastModifiedMs: number,
): Promise<ParsedExtractedMetadata> {
+ let file: File;
+ if (fileOrPath instanceof File) {
+ file = fileOrPath;
+ } else {
+ const path = fileOrPath;
+ // The library we use for extracting EXIF from images, exifr, doesn't
+ // support streams. But unlike videos, for images it is reasonable to
+ // read the entire stream into memory here.
+ const { response } = await readStream(ensureElectron(), path);
+ file = new File([await response.arrayBuffer()], basename(path), {
+ lastModified: lastModifiedMs,
+ });
+ }
+
try {
- if (!(fileOrPath instanceof File)) {
- fileOrPath = new File([await fileOrPath.blob()], fileOrPath.name, {
- lastModified: lastModifiedMs,
- });
- }
- return await parseImageMetadata(fileOrPath, fileTypeInfo);
+ return await parseImageMetadata(file, fileTypeInfo);
} catch (e) {
log.error(`Failed to extract image metadata for ${fileOrPath}`, e);
return undefined;