clone cached media/directories before sending them back to the app

This commit is contained in:
tibbi 2018-05-26 09:53:41 +02:00
parent 713ba852c2
commit ad07068475

View file

@ -293,9 +293,10 @@ fun Context.getCachedDirectories(getVideosOnly: Boolean = false, getImagesOnly:
} }
}) as ArrayList<Directory> }) as ArrayList<Directory>
callback(filteredDirectories.distinctBy { it.path.getDistinctPath() } as ArrayList<Directory>) val clone = filteredDirectories.clone() as ArrayList<Directory>
callback(clone.distinctBy { it.path.getDistinctPath() } as ArrayList<Directory>)
removeInvalidDBDirectories(directories, directoryDao) removeInvalidDBDirectories(filteredDirectories, directoryDao)
}.start() }.start()
} }
@ -326,7 +327,7 @@ fun Context.getCachedMedia(path: String, getVideosOnly: Boolean = false, getImag
}) as ArrayList<Medium> }) as ArrayList<Medium>
MediaFetcher(this).sortMedia(media, config.getFileSorting(path)) MediaFetcher(this).sortMedia(media, config.getFileSorting(path))
callback(media) callback(media.clone() as ArrayList<Medium>)
media.filter { !getDoesFilePathExist(it.path) }.forEach { media.filter { !getDoesFilePathExist(it.path) }.forEach {
mediumDao.deleteMediumPath(it.path) mediumDao.deleteMediumPath(it.path)