Skip to content

armgit / ente

Public Imported from GitHub
0

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

Inline

Manav Rathi6f6ade1901fd
diff --git a/web/apps/photos/src/constants/upload.ts b/web/apps/photos/src/constants/upload.ts
index 75918fae0b..b188626dff 100644
--- a/web/apps/photos/src/constants/upload.ts
+++ b/web/apps/photos/src/constants/upload.ts
@@ -46,8 +46,6 @@ export const WHITELISTED_FILE_FORMATS: FileTypeInfo[] = [
export const KNOWN_NON_MEDIA_FORMATS = ["xmp", "html", "txt"];
-export const EXIFLESS_FORMATS = ["gif", "bmp"];
-
// this is the chunk size of the un-encrypted file which is read and encrypted before uploading it as a single part.
export const MULTIPART_PART_SIZE = 20 * 1024 * 1024;
diff --git a/web/apps/photos/src/services/upload/exifService.ts b/web/apps/photos/src/services/upload/exifService.ts
index a26075b3af..42afb7618b 100644
--- a/web/apps/photos/src/services/upload/exifService.ts
+++ b/web/apps/photos/src/services/upload/exifService.ts
@@ -1,13 +1,11 @@
import log from "@/next/log";
import { CustomError } from "@ente/shared/error";
import { validateAndGetCreationUnixTimeInMicroSeconds } from "@ente/shared/time";
-import { EXIFLESS_FORMATS, NULL_LOCATION } from "constants/upload";
+import { NULL_LOCATION } from "constants/upload";
import exifr from "exifr";
import piexif from "piexifjs";
import { FileTypeInfo, Location } from "types/upload";
-const EXIFR_UNSUPPORTED_FILE_FORMAT_MESSAGE = "Unknown file format";
-
type ParsedEXIFData = Record<string, any> &
Partial<{
DateTimeOriginal: Date;
@@ -38,11 +36,14 @@ type RawEXIFData = Record<string, any> &
export async function getParsedExifData(
receivedFile: File,
- fileTypeInfo: FileTypeInfo,
+ { exactType }: FileTypeInfo,
tags?: string[],
): Promise<ParsedEXIFData> {
+ const exifLessFormats = ["gif", "bmp"];
+ const exifrUnsupportedFileFormatMessage = "Unknown file format";
+
try {
- if (EXIFLESS_FORMATS.includes(fileTypeInfo.exactType)) {
+ if (exifLessFormats.includes(exactType)) {
return null;
}
const exifData: RawEXIFData = await exifr.parse(receivedFile, {
@@ -66,16 +67,11 @@ export async function getParsedExifData(
: exifData;
return parseExifData(filteredExifData);
} catch (e) {
- if (e.message === EXIFR_UNSUPPORTED_FILE_FORMAT_MESSAGE) {
- log.error(
- `exif library unsupported format ${fileTypeInfo.exactType}`,
- e,
- );
+ if (e.message == exifrUnsupportedFileFormatMessage) {
+ log.error(`EXIFR does not support format ${exactType}`, e);
+ return undefined;
} else {
- log.error(
- `get parsed exif data failed for file type ${fileTypeInfo.exactType}`,
- e,
- );
+ log.error(`Failed to parse EXIF data of ${exactType} file`, e);
throw e;
}
}