diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/String.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/String.kt index a8f4a9f57..ad9a4ec58 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/String.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/String.kt @@ -3,6 +3,7 @@ package com.simplemobiletools.gallery.extensions import com.bumptech.glide.signature.ObjectKey import com.simplemobiletools.commons.helpers.OTG_PATH import java.io.File +import java.io.IOException fun String.getFileSignature(): ObjectKey { val file = File(this) @@ -35,4 +36,10 @@ fun String.shouldFolderBeVisible(excludedPaths: MutableSet, includedPath } // recognize /sdcard/DCIM as the same folder as /storage/emulated/0/DCIM -fun String.getDistinctPath() = if (startsWith(OTG_PATH)) toLowerCase() else File(this).canonicalPath.toLowerCase() +fun String.getDistinctPath(): String { + return try { + if (startsWith(OTG_PATH)) toLowerCase() else File(this).canonicalPath.toLowerCase() + } catch (e: IOException) { + toLowerCase() + } +}