Manav Rathi 1 год назад
Родитель
Сommit
81c729a405
2 измененных файлов с 4 добавлено и 7 удалено
  1. 4 5
      web/apps/photos/src/services/upload/exifService.ts
  2. 0 2
      web/packages/shared/error/index.ts

+ 4 - 5
web/apps/photos/src/services/upload/exifService.ts

@@ -1,5 +1,4 @@
 import log from "@/next/log";
 import log from "@/next/log";
-import { CustomError } from "@ente/shared/error";
 import { validateAndGetCreationUnixTimeInMicroSeconds } from "@ente/shared/time";
 import { validateAndGetCreationUnixTimeInMicroSeconds } from "@ente/shared/time";
 import { NULL_LOCATION } from "constants/upload";
 import { NULL_LOCATION } from "constants/upload";
 import exifr from "exifr";
 import exifr from "exifr";
@@ -176,7 +175,7 @@ function parseExifData(exifData: RawEXIFData): ParsedEXIFData {
 function parseEXIFDate(dateTimeString: string) {
 function parseEXIFDate(dateTimeString: string) {
     try {
     try {
         if (typeof dateTimeString !== "string" || dateTimeString === "") {
         if (typeof dateTimeString !== "string" || dateTimeString === "") {
-            throw Error(CustomError.NOT_A_DATE);
+            throw new Error("Invalid date string");
         }
         }
 
 
         // Check and parse date in the format YYYYMMDD
         // Check and parse date in the format YYYYMMDD
@@ -207,7 +206,7 @@ function parseEXIFDate(dateTimeString: string) {
             typeof day === "undefined" ||
             typeof day === "undefined" ||
             Number.isNaN(day)
             Number.isNaN(day)
         ) {
         ) {
-            throw Error(CustomError.NOT_A_DATE);
+            throw new Error("Invalid date");
         }
         }
         let date: Date;
         let date: Date;
         if (
         if (
@@ -223,7 +222,7 @@ function parseEXIFDate(dateTimeString: string) {
             date = new Date(year, month - 1, day, hour, minute, second);
             date = new Date(year, month - 1, day, hour, minute, second);
         }
         }
         if (Number.isNaN(+date)) {
         if (Number.isNaN(+date)) {
-            throw Error(CustomError.NOT_A_DATE);
+            throw new Error("Invalid date");
         }
         }
         return date;
         return date;
     } catch (e) {
     } catch (e) {
@@ -245,7 +244,7 @@ export function parseEXIFLocation(
             gpsLatitude.length !== 3 ||
             gpsLatitude.length !== 3 ||
             gpsLongitude.length !== 3
             gpsLongitude.length !== 3
         ) {
         ) {
-            throw Error(CustomError.NOT_A_LOCATION);
+            throw new Error("Invalid EXIF location");
         }
         }
         const latitude = convertDMSToDD(
         const latitude = convertDMSToDD(
             gpsLatitude[0],
             gpsLatitude[0],

+ 0 - 2
web/packages/shared/error/index.ts

@@ -48,8 +48,6 @@ export const CustomError = {
     SUBSCRIPTION_NEEDED: "subscription not present",
     SUBSCRIPTION_NEEDED: "subscription not present",
     NOT_FOUND: "not found ",
     NOT_FOUND: "not found ",
     NO_METADATA: "no metadata",
     NO_METADATA: "no metadata",
-    NOT_A_DATE: "not a date",
-    NOT_A_LOCATION: "not a location",
     FILE_ID_NOT_FOUND: "file with id not found",
     FILE_ID_NOT_FOUND: "file with id not found",
     WEAK_DEVICE: "password decryption failed on the device",
     WEAK_DEVICE: "password decryption failed on the device",
     INCORRECT_PASSWORD: "incorrect password",
     INCORRECT_PASSWORD: "incorrect password",