From 4e15f047c5cad0c5c6b9aba5953d3c879551b40c Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 28 Jan 2018 17:29:15 +0100 Subject: [PATCH] add an extra check to avoid removing valid files --- .../com/simplemobiletools/gallery/helpers/MediaFetcher.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt index 8f5eb9dec..e0e797f0f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt @@ -43,8 +43,11 @@ class MediaFetcher(val context: Context) { Thread { val ONE_WEEK = 7 * 24 * 60 * 60 * 1000 if (System.currentTimeMillis() - context.config.lastFileCleanup > ONE_WEEK) { - media.filter { !File(it.path).exists() }.forEach { - context.deleteFromMediaStore(File(it.path)) + media.forEach { + val file = File(it.path) + if (!it.path.contains("/.thumbnails") && !file.exists() && file.length() == 0L) { + context.deleteFromMediaStore(file) + } } context.config.lastFileCleanup = System.currentTimeMillis() }