From 2bd6614b9b8c57f8aaf65913778890134b045ee6 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 28 Jun 2021 19:00:24 +0200 Subject: [PATCH] catch exceptions thrown at deleting media from db --- .../simplemobiletools/gallery/pro/extensions/Context.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt index 55f480b4f..022bb4761 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt @@ -742,10 +742,13 @@ fun Context.getCachedMedia(path: String, getVideosOnly: Boolean = false, getImag } if (mediaToDelete.isNotEmpty()) { - mediaDB.deleteMedia(*mediaToDelete.toTypedArray()) + try { + mediaDB.deleteMedia(*mediaToDelete.toTypedArray()) - mediaToDelete.filter { it.isFavorite }.forEach { - favoritesDB.deleteFavoritePath(it.path) + mediaToDelete.filter { it.isFavorite }.forEach { + favoritesDB.deleteFavoritePath(it.path) + } + } catch (ignored: Exception) { } } }.start()