From 4b49cdf34f08f7871a1f7b74ed097205196e7a9c Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 22 Feb 2019 10:25:38 +0100 Subject: [PATCH] always clean up invalid files, not just at 20% --- .../gallery/pro/extensions/Context.kt | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 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 45c3eeb64..df67d2b61 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 @@ -42,7 +42,6 @@ import java.util.HashSet import java.util.LinkedHashSet import kotlin.Comparator import kotlin.collections.ArrayList -import kotlin.random.Random val Context.portrait get() = resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT val Context.audioManager get() = getSystemService(Context.AUDIO_SERVICE) as AudioManager @@ -565,23 +564,20 @@ fun Context.getCachedMedia(path: String, getVideosOnly: Boolean = false, getImag val grouped = mediaFetcher.groupMedia(media, pathToUse) callback(grouped.clone() as ArrayList) - val value = Random.nextInt(5) - if (value == 1) { - val mediaToDelete = ArrayList() - media.filter { !File(it.path).exists() }.forEach { - if (it.path.startsWith(recycleBinPath)) { - deleteDBPath(mediumDao, it.path) - } else { - mediaToDelete.add(it) - } + val mediaToDelete = ArrayList() + media.filter { !File(it.path).exists() }.forEach { + if (it.path.startsWith(recycleBinPath)) { + deleteDBPath(mediumDao, it.path) + } else { + mediaToDelete.add(it) } + } - try { - if (mediaToDelete.isNotEmpty()) { - mediumDao.deleteMedia(*mediaToDelete.toTypedArray()) - } - } catch (ignored: Exception) { + try { + if (mediaToDelete.isNotEmpty()) { + mediumDao.deleteMedia(*mediaToDelete.toTypedArray()) } + } catch (ignored: Exception) { } }.start() }