|
@@ -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],
|