mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 22:47:59 +01:00
do not check every file existence at fetching, just once a week do a cleanup
This commit is contained in:
parent
b9187adfc0
commit
da80d24606
4 changed files with 16 additions and 4 deletions
|
@ -42,7 +42,7 @@ ext {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.simplemobiletools:commons:3.4.2'
|
||||
implementation 'com.simplemobiletools:commons:3.4.15'
|
||||
implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.9.0'
|
||||
implementation 'com.theartofdev.edmodo:android-image-cropper:2.6.0'
|
||||
implementation 'com.android.support:multidex:1.0.2'
|
||||
|
|
|
@ -300,4 +300,8 @@ class Config(context: Context) : BaseConfig(context) {
|
|||
var extendedDetails: Int
|
||||
get() = prefs.getInt(EXTENDED_DETAILS, EXT_RESOLUTION or EXT_LAST_MODIFIED or EXT_EXIF_PROPERTIES)
|
||||
set(extendedDetails) = prefs.edit().putInt(EXTENDED_DETAILS, extendedDetails).apply()
|
||||
|
||||
var lastFileCleanup: Long
|
||||
get() = prefs.getLong(LAST_FILE_CLEANUP, 0L)
|
||||
set(lastFileCleanup) = prefs.edit().putLong(LAST_FILE_CLEANUP, lastFileCleanup).apply()
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ val VIEW_TYPE_FOLDERS = "view_type_folders"
|
|||
val VIEW_TYPE_FILES = "view_type_files"
|
||||
val SHOW_EXTENDED_DETAILS = "show_extended_details"
|
||||
val EXTENDED_DETAILS = "extended_details"
|
||||
val LAST_FILE_CLEANUP = "last_file_cleanup"
|
||||
|
||||
// slideshow
|
||||
val SLIDESHOW_INTERVAL = "slideshow_interval"
|
||||
|
|
|
@ -40,6 +40,16 @@ class MediaFetcher(val context: Context) {
|
|||
directories.remove(it)
|
||||
}
|
||||
|
||||
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))
|
||||
}
|
||||
context.config.lastFileCleanup = System.currentTimeMillis()
|
||||
}
|
||||
}.start()
|
||||
|
||||
return directories
|
||||
}
|
||||
|
||||
|
@ -140,9 +150,6 @@ class MediaFetcher(val context: Context) {
|
|||
if (size <= 0L)
|
||||
continue
|
||||
|
||||
if (!file.exists())
|
||||
continue
|
||||
|
||||
val dateTaken = cur.getLongValue(MediaStore.Images.Media.DATE_TAKEN)
|
||||
val dateModified = cur.getIntValue(MediaStore.Images.Media.DATE_MODIFIED) * 1000L
|
||||
|
||||
|
|
Loading…
Reference in a new issue