From 6ed13c7afa69bf4d91c1c75132a7a35208996f08 Mon Sep 17 00:00:00 2001 From: sonalyadav Date: Thu, 19 Dec 2024 19:24:05 +0530 Subject: [PATCH] null value fixing --- .../fr/free/nrw/commons/utils/CustomSelectorUtils.kt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/fr/free/nrw/commons/utils/CustomSelectorUtils.kt b/app/src/main/java/fr/free/nrw/commons/utils/CustomSelectorUtils.kt index 62bd3f1a9..15ce2178b 100644 --- a/app/src/main/java/fr/free/nrw/commons/utils/CustomSelectorUtils.kt +++ b/app/src/main/java/fr/free/nrw/commons/utils/CustomSelectorUtils.kt @@ -53,14 +53,17 @@ class CustomSelectorUtils { ): String = withContext(defaultDispatcher) { val uploadableFile = PickedFiles.pickedExistingPicture(context, image.uri) - val exifInterface: ExifInterface? = + val exifInterface: ExifInterface? = uploadableFile.file?.let { file -> try { - ExifInterface(uploadableFile.file!!) + ExifInterface(file) // Only create ExifInterface if file is not null } catch (e: IOException) { - Timber.e(e) + Timber.e(e, "Error reading EXIF data") null } - fileProcessor.redactExifTags(exifInterface, fileProcessor.getExifTagsToRedact()) + } + // Redact EXIF tags if exifInterface is not null + exifInterface?.let { + fileProcessor.redactExifTags(exifInterface, fileProcessor.getExifTagsToRedact()) } val sha1 = fileUtilsWrapper.getSHA1( fileUtilsWrapper.getFileInputStream(uploadableFile.getFilePath()),