catch IOExceptions at getting some file paths

This commit is contained in:
tibbi 2018-06-17 21:57:48 +02:00
parent dddfea3b1e
commit 875ba99dc0

View file

@ -3,6 +3,7 @@ package com.simplemobiletools.gallery.extensions
import com.bumptech.glide.signature.ObjectKey import com.bumptech.glide.signature.ObjectKey
import com.simplemobiletools.commons.helpers.OTG_PATH import com.simplemobiletools.commons.helpers.OTG_PATH
import java.io.File import java.io.File
import java.io.IOException
fun String.getFileSignature(): ObjectKey { fun String.getFileSignature(): ObjectKey {
val file = File(this) val file = File(this)
@ -35,4 +36,10 @@ fun String.shouldFolderBeVisible(excludedPaths: MutableSet<String>, includedPath
} }
// recognize /sdcard/DCIM as the same folder as /storage/emulated/0/DCIM // 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()
}
}