From af96e7731347ba2963b4902b3d31f09c729b8c8c Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 28 Jul 2019 19:50:15 +0200 Subject: [PATCH] catching some exceptions at adding media in db --- .../gallery/pro/extensions/Context.kt | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 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 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()