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 577cd653e..20d078c80 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 @@ -401,15 +401,18 @@ fun Context.rescanFolderMediaSync(path: String) { val newMedia = it val mediumDao = galleryDB.MediumDao() val media = newMedia.filter { it is Medium } as ArrayList - mediumDao.insertAll(media) + try { + mediumDao.insertAll(media) - cached.forEach { - if (!newMedia.contains(it)) { - val mediumPath = (it as? Medium)?.path - if (mediumPath != null) { - deleteDBPath(mediumDao, mediumPath) + cached.forEach { + if (!newMedia.contains(it)) { + val mediumPath = (it as? Medium)?.path + if (mediumPath != null) { + deleteDBPath(mediumDao, mediumPath) + } } } + } catch (ignored: Exception) { } } }.execute()