mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-23 04:57:59 +01:00
add an extra check to avoid removing valid files
This commit is contained in:
parent
95e5480d03
commit
4e15f047c5
1 changed files with 5 additions and 2 deletions
|
@ -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()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue