From ed8fa63ce8b03d32d6f147926cfcd6e040bc72b1 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 27 Jun 2018 15:20:45 +0200 Subject: [PATCH] make sure we clean up invalid recycle bin db entries --- .../com/simplemobiletools/gallery/extensions/Context.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Context.kt index 7b8195b7d..086102b1e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Context.kt @@ -364,8 +364,13 @@ fun Context.getCachedMedia(path: String, getVideosOnly: Boolean = false, getImag val grouped = mediaFetcher.groupMedia(media, path) callback(grouped.clone() as ArrayList) + val recycleBinPath = filesDir.toString() media.filter { !getDoesFilePathExist(it.path) }.forEach { - mediumDao.deleteMediumPath(it.path) + if (it.path.startsWith(recycleBinPath)) { + mediumDao.deleteMediumPath(it.path.removePrefix(recycleBinPath)) + } else { + mediumDao.deleteMediumPath(it.path) + } } }.start() }