Merge pull request #258 from ente-io/master

release
This commit is contained in:
abhinavkgrd 2021-11-30 11:51:04 +05:30 committed by GitHub
commit 03595c6888
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -31,9 +31,14 @@ export async function getExifData(
receivedFile: globalThis.File, receivedFile: globalThis.File,
fileTypeInfo: FileTypeInfo fileTypeInfo: FileTypeInfo
): Promise<ParsedEXIFData> { ): Promise<ParsedEXIFData> {
const nullExifData: ParsedEXIFData = {
location: NULL_LOCATION,
creationTime: null,
};
try {
const exifData = await getRawExif(receivedFile, fileTypeInfo); const exifData = await getRawExif(receivedFile, fileTypeInfo);
if (!exifData) { if (!exifData) {
return { location: NULL_LOCATION, creationTime: null }; return nullExifData;
} }
const parsedEXIFData = { const parsedEXIFData = {
location: getEXIFLocation(exifData), location: getEXIFLocation(exifData),
@ -44,6 +49,10 @@ export async function getExifData(
), ),
}; };
return parsedEXIFData; return parsedEXIFData;
} catch (e) {
logError(e, 'getExifData failed');
return nullExifData;
}
} }
export async function getRawExif( export async function getRawExif(
@ -63,6 +72,7 @@ export async function getRawExif(
} }
export function getUNIXTime(dateTime: Date) { export function getUNIXTime(dateTime: Date) {
try {
if (!dateTime) { if (!dateTime) {
return null; return null;
} }
@ -72,6 +82,9 @@ export function getUNIXTime(dateTime: Date) {
} else { } else {
return unixTime; return unixTime;
} }
} catch (e) {
logError(e, 'getUNIXTime failed', { dateTime });
}
} }
function getEXIFLocation(exifData): Location { function getEXIFLocation(exifData): Location {