make sure we clean up invalid recycle bin db entries

This commit is contained in:
tibbi 2018-06-27 15:20:45 +02:00
parent 59cb293d98
commit ed8fa63ce8

View file

@ -364,8 +364,13 @@ fun Context.getCachedMedia(path: String, getVideosOnly: Boolean = false, getImag
val grouped = mediaFetcher.groupMedia(media, path)
callback(grouped.clone() as ArrayList<ThumbnailItem>)
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()
}