Skip to content

Commit 69aa9d1

Browse files
committed
fix: crash on exists method.
1 parent 73bf385 commit 69aa9d1

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

dfc/src/main/java/com/lazygeniouz/dfc/resolver/ResolverCompat.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,14 @@ internal object ResolverCompat {
8989
* Returns True if the Document Folder / File exists, False otherwise.
9090
*/
9191
internal fun exists(context: Context, uri: Uri): Boolean {
92-
getCursor(context, uri, idProjection)?.use { cursor -> return (cursor.count > 0) }
93-
return false
92+
return try {
93+
getCursor(context, uri, idProjection)?.use { cursor ->
94+
cursor.count > 0
95+
} ?: false
96+
} catch (exception: Exception) {
97+
ErrorLogger.logError("Exception while checking if the uri exists", exception)
98+
false
99+
}
94100
}
95101

96102
/**

0 commit comments

Comments
 (0)