From 331b016a95e23b502737a753a67a6aac4799b57a Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 17 Jun 2019 16:51:18 +0200 Subject: [PATCH] extending the try/catch block at adding paths to db --- .../gallery/pro/extensions/Context.kt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 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 ac45129b3..c6582ccc2 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 @@ -781,12 +781,13 @@ fun Context.addPathToDB(path: String) { else -> TYPE_IMAGES } - val mediumDao = galleryDB.MediumDao() - val isFavorite = mediumDao.isFavorite(path) - val videoDuration = if (type == TYPE_VIDEOS) path.getVideoDuration() else 0 - val medium = Medium(null, path.getFilenameFromPath(), path, path.getParentPath(), System.currentTimeMillis(), System.currentTimeMillis(), - File(path).length(), type, videoDuration, isFavorite, 0L) try { + val mediumDao = galleryDB.MediumDao() + val isFavorite = mediumDao.isFavorite(path) + val videoDuration = if (type == TYPE_VIDEOS) path.getVideoDuration() else 0 + val medium = Medium(null, path.getFilenameFromPath(), path, path.getParentPath(), System.currentTimeMillis(), System.currentTimeMillis(), + File(path).length(), type, videoDuration, isFavorite, 0L) + mediumDao.insert(medium) } catch (ignored: Exception) { }