From a6057f7fe40be81a41dbc895f946225972d95a9d Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 23 Oct 2021 21:54:42 +0200 Subject: [PATCH] be more agressive at deleting corrupt cached files --- .../gallery/pro/activities/MediaActivity.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt index e2e7278c6..052cf2c0b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt @@ -611,12 +611,14 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { val newMedia = it try { gotMedia(newMedia, false) - oldMedia.filter { !newMedia.contains(it) }.mapNotNull { it as? Medium }.forEach { - if (!getDoesFilePathExist(it.path)) { - mediaDB.deleteMediumPath(it.path) - } else if (mPath == FAVORITES) { + + val newPaths = newMedia.mapNotNull { it as? Medium }.map { it.path } + oldMedia.mapNotNull { it as? Medium }.filter { !newPaths.contains(it.path) }.forEach { + if (mPath == FAVORITES && getDoesFilePathExist(it.path)) { favoritesDB.deleteFavoritePath(it.path) mediaDB.updateFavorite(it.path, false) + } else { + mediaDB.deleteMediumPath(it.path) } } } catch (e: Exception) {