From 3b1fd78fbe02a1330dee446c07445878e3e1c6fe Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Mon, 22 Jul 2024 15:21:35 +0530 Subject: [PATCH] Selective handling --- web/apps/photos/src/utils/file/index.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/web/apps/photos/src/utils/file/index.ts b/web/apps/photos/src/utils/file/index.ts index d0ee1f9f03..394468294c 100644 --- a/web/apps/photos/src/utils/file/index.ts +++ b/web/apps/photos/src/utils/file/index.ts @@ -129,12 +129,18 @@ export const updateExifIfNeeded = async ( ); return updatedBlob.stream(); } catch (e) { - // We used the file's extension to determine if this was a JPEG, but - // this is not a guarantee. Misnamed files, while rare, do exist. So - // in case of errors, return the original back instead of causing the - // entire download or export to fail. log.error(`Failed to modify Exif date for ${fileName}`, e); - return blob.stream(); + // We used the file's extension to determine if this was a JPEG, but + // this is not a guarantee. Misnamed files, while rare, do exist. So in + // that is the error thrown by the underlying library, fallback to the + // original instead of causing the entire download or export to fail. + if ( + e instanceof Error && + e.message.endsWith("Given file is neither JPEG nor TIFF") + ) { + return blob.stream(); + } + throw e; } };