fix some data consistency issues when fetching recycle bin items
This commit is contained in:
parent
ed8fa63ce8
commit
e0f8d311ba
|
@ -211,25 +211,30 @@ class MediaFetcher(val context: Context) {
|
||||||
if (size <= 0L || (doExtraCheck && !file.exists()))
|
if (size <= 0L || (doExtraCheck && !file.exists()))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
val lastModified = file.lastModified()
|
|
||||||
var dateTaken = lastModified
|
|
||||||
|
|
||||||
if (getProperDateTaken) {
|
|
||||||
dateTaken = dateTakens.remove(filename) ?: lastModified
|
|
||||||
}
|
|
||||||
|
|
||||||
val type = when {
|
|
||||||
isImage -> TYPE_IMAGES
|
|
||||||
isVideo -> TYPE_VIDEOS
|
|
||||||
isGif -> TYPE_GIFS
|
|
||||||
else -> TYPE_RAWS
|
|
||||||
}
|
|
||||||
|
|
||||||
val path = file.absolutePath
|
val path = file.absolutePath
|
||||||
val isFavorite = favoritePaths.contains(path)
|
if (folder == RECYCLE_BIN) {
|
||||||
val deletedTS = if (folder == RECYCLE_BIN) deletedMedia.firstOrNull { it.path == path }?.deletedTS ?: 0L else 0L
|
deletedMedia.firstOrNull { it.path == path }?.apply {
|
||||||
val medium = Medium(null, filename, path, file.parent, lastModified, dateTaken, size, type, isFavorite, deletedTS)
|
media.add(this)
|
||||||
media.add(medium)
|
}
|
||||||
|
} else {
|
||||||
|
val lastModified = file.lastModified()
|
||||||
|
var dateTaken = lastModified
|
||||||
|
|
||||||
|
if (getProperDateTaken) {
|
||||||
|
dateTaken = dateTakens.remove(filename) ?: lastModified
|
||||||
|
}
|
||||||
|
|
||||||
|
val type = when {
|
||||||
|
isImage -> TYPE_IMAGES
|
||||||
|
isVideo -> TYPE_VIDEOS
|
||||||
|
isGif -> TYPE_GIFS
|
||||||
|
else -> TYPE_RAWS
|
||||||
|
}
|
||||||
|
|
||||||
|
val isFavorite = favoritePaths.contains(path)
|
||||||
|
val medium = Medium(null, filename, path, file.parent, lastModified, dateTaken, size, type, isFavorite, 0L)
|
||||||
|
media.add(medium)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return media
|
return media
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue