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) { }