diff --git a/src/components/PhotoViewer/index.tsx b/src/components/PhotoViewer/index.tsx index a67ffde9d..c0643d329 100644 --- a/src/components/PhotoViewer/index.tsx +++ b/src/components/PhotoViewer/index.tsx @@ -454,7 +454,9 @@ function PhotoViewer(props: Iprops) { } catch (e) { setExif({ key: file.src, value: null }); const fileExtension = getFileExtension(file.metadata.title); - logError(e, 'exifr parsing failed', { extension: fileExtension }); + logError(e, 'checkExifAvailable failed', { + extension: fileExtension, + }); } }; diff --git a/src/constants/upload/index.ts b/src/constants/upload/index.ts index 7c4969b93..d9aefa1b3 100644 --- a/src/constants/upload/index.ts +++ b/src/constants/upload/index.ts @@ -7,7 +7,7 @@ import { } from 'types/upload'; // list of format that were missed by type-detection for some files. -export const FORMAT_MISSED_BY_FILE_TYPE_LIB = [ +export const FILE_TYPE_LIB_MISSED_FORMATS = [ { fileType: FILE_TYPE.IMAGE, exactType: 'jpeg', mimeType: 'image/jpeg' }, { fileType: FILE_TYPE.IMAGE, exactType: 'jpg', mimeType: 'image/jpeg' }, { fileType: FILE_TYPE.VIDEO, exactType: 'webm', mimeType: 'video/webm' }, @@ -15,6 +15,10 @@ export const FORMAT_MISSED_BY_FILE_TYPE_LIB = [ { fileType: FILE_TYPE.VIDEO, exactType: 'mp4', mimeType: 'video/mp4' }, ]; +export const EXIFLESS_FORMATS = ['image/gif']; + +export const EXIF_LIBRARY_UNSUPPORTED_FORMATS = ['image/webp']; + // 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/src/services/typeDetectionService.ts b/src/services/typeDetectionService.ts index 97ccd53e5..d7eaa62b9 100644 --- a/src/services/typeDetectionService.ts +++ b/src/services/typeDetectionService.ts @@ -1,6 +1,6 @@ import { FILE_TYPE } from 'constants/file'; import { ElectronFile, FileTypeInfo } from 'types/upload'; -import { FORMAT_MISSED_BY_FILE_TYPE_LIB } from 'constants/upload'; +import { FILE_TYPE_LIB_MISSED_FORMATS } from 'constants/upload'; import { CustomError } from 'utils/error'; import { getFileExtension } from 'utils/file'; import { logError } from 'utils/sentry'; @@ -46,7 +46,7 @@ export async function getFileType( }; } catch (e) { const fileFormat = getFileExtension(receivedFile.name); - const formatMissedByTypeDetection = FORMAT_MISSED_BY_FILE_TYPE_LIB.find( + const formatMissedByTypeDetection = FILE_TYPE_LIB_MISSED_FORMATS.find( (a) => a.exactType === fileFormat ); if (formatMissedByTypeDetection) { diff --git a/src/services/upload/exifService.ts b/src/services/upload/exifService.ts index 9cbb11fac..70153fe38 100644 --- a/src/services/upload/exifService.ts +++ b/src/services/upload/exifService.ts @@ -1,4 +1,9 @@ -import { NULL_EXTRACTED_METADATA, NULL_LOCATION } from 'constants/upload'; +import { + EXIFLESS_FORMATS, + EXIF_LIBRARY_UNSUPPORTED_FORMATS, + NULL_EXTRACTED_METADATA, + NULL_LOCATION, +} from 'constants/upload'; import { ElectronFile, Location } from 'types/upload'; import exifr from 'exifr'; import piexif from 'piexifjs'; @@ -121,10 +126,19 @@ export async function getRawExif( try { exifData = await exifr.parse(receivedFile, EXIF_TAGS_NEEDED); } catch (e) { - logError(e, 'file missing exif data ', { - fileType: fileTypeInfo.exactType, - }); - // ignore exif parsing errors + if (!EXIFLESS_FORMATS.includes(fileTypeInfo.mimeType)) { + if ( + EXIF_LIBRARY_UNSUPPORTED_FORMATS.includes(fileTypeInfo.mimeType) + ) { + logError(e, 'exif library unsupported format', { + fileType: fileTypeInfo.exactType, + }); + } else { + logError(e, 'get raw exif failed', { + fileType: fileTypeInfo.exactType, + }); + } + } } return exifData; }