fix #1449, do not wipe favorite items at fixing date taken values

This commit is contained in:
tibbi 2019-06-11 16:46:05 +02:00
parent 68ded4bfa9
commit 08ee4c60ef
2 changed files with 7 additions and 2 deletions

View file

@ -781,11 +781,13 @@ fun Context.addPathToDB(path: String) {
else -> TYPE_IMAGES
}
val mediumDao = galleryDB.MediumDao()
val isFavorite = mediumDao.isFavorite(path)
val videoDuration = if (type == TYPE_VIDEOS) path.getVideoDuration() else 0
val medium = Medium(null, path.getFilenameFromPath(), path, path.getParentPath(), System.currentTimeMillis(), System.currentTimeMillis(),
File(path).length(), type, videoDuration, false, 0L)
File(path).length(), type, videoDuration, isFavorite, 0L)
try {
galleryDB.MediumDao().insert(medium)
mediumDao.insert(medium)
} catch (ignored: Exception) {
}
}.start()

View file

@ -21,6 +21,9 @@ interface MediumDao {
@Query("SELECT filename, full_path, parent_path, last_modified, date_taken, size, type, video_duration, is_favorite, deleted_ts FROM media WHERE deleted_ts != 0")
fun getDeletedMedia(): List<Medium>
@Query("SELECT is_favorite FROM media WHERE full_path = :path")
fun isFavorite(path: String): Boolean
@Insert(onConflict = REPLACE)
fun insert(medium: Medium)