update Favorite too at updating a medium

This commit is contained in:
tibbi 2020-01-25 11:50:09 +01:00
parent e578036a22
commit 29a521d107
3 changed files with 6 additions and 2 deletions

View file

@ -697,7 +697,8 @@ fun Context.updateDBMediaPath(oldPath: String, newPath: String) {
val newFilename = newPath.getFilenameFromPath()
val newParentPath = newPath.getParentPath()
try {
mediaDB.updateMedium(oldPath, newParentPath, newFilename, newPath)
mediaDB.updateMedium(newFilename, newPath, newParentPath, oldPath)
favoritesDB.updateFavorite(newFilename, newPath, newParentPath, oldPath)
} catch (ignored: Exception) {
}
}

View file

@ -20,6 +20,9 @@ interface FavoritesDao {
@Query("SELECT id FROM favorites WHERE full_path = :path COLLATE NOCASE")
fun isFavorite(path: String): Boolean
@Query("UPDATE OR REPLACE favorites SET filename = :newFilename, full_path = :newFullPath, parent_path = :newParentPath WHERE full_path = :oldPath COLLATE NOCASE")
fun updateFavorite(newFilename: String, newFullPath: String, newParentPath: String, oldPath: String)
@Delete
fun deleteFavorites(vararg favorite: Favorite)

View file

@ -34,7 +34,7 @@ interface MediumDao {
fun deleteOldRecycleBinItems(timestmap: Long)
@Query("UPDATE OR REPLACE media SET filename = :newFilename, full_path = :newFullPath, parent_path = :newParentPath WHERE full_path = :oldPath COLLATE NOCASE")
fun updateMedium(oldPath: String, newParentPath: String, newFilename: String, newFullPath: String)
fun updateMedium(newFilename: String, newFullPath: String, newParentPath: String, oldPath: String)
@Query("UPDATE OR REPLACE media SET full_path = :newPath, deleted_ts = :deletedTS WHERE full_path = :oldPath COLLATE NOCASE")
fun updateDeleted(newPath: String, deletedTS: Long, oldPath: String)