music: lowercase names when hashing
Lowercase music names when hashing them to prevent drift stemming from grouping. The addition of the song may change the case of an artist if such mitigations are in effect. To prevent such from invalidating music hashes, we take the lowercase of every name hashed.
This commit is contained in:
parent
51b9b0e734
commit
10362b9efc
2 changed files with 8 additions and 7 deletions
|
@ -15,6 +15,7 @@ at the cost of longer loading times
|
|||
- Fixed shuffle shortcut and file opening not working on startup on some devices
|
||||
|
||||
#### What's Changed
|
||||
- Play and skip icons are filled again
|
||||
- Updated music hashing (Will wipe playback state)
|
||||
|
||||
## 2.5.0
|
||||
|
|
|
@ -110,9 +110,9 @@ data class Song(
|
|||
) : Music() {
|
||||
override val id: Long
|
||||
get() {
|
||||
var result = rawName.hashCode().toLong()
|
||||
result = 31 * result + album.rawName.hashCode()
|
||||
result = 31 * result + (album.artist.rawName ?: MediaStore.UNKNOWN_STRING).hashCode()
|
||||
var result = rawName.lowercase().hashCode().toLong()
|
||||
result = 31 * result + album.rawName.lowercase().hashCode()
|
||||
result = 31 * result + (album.artist.rawName?.lowercase() ?: MediaStore.UNKNOWN_STRING).hashCode()
|
||||
result = 31 * result + (track ?: 0)
|
||||
result = 31 * result + (disc ?: 0)
|
||||
result = 31 * result + durationMs
|
||||
|
@ -218,8 +218,8 @@ data class Album(
|
|||
|
||||
override val id: Long
|
||||
get() {
|
||||
var result = rawName.hashCode().toLong()
|
||||
result = 31 * result + (artist.rawName ?: MediaStore.UNKNOWN_STRING).hashCode()
|
||||
var result = rawName.lowercase().hashCode().toLong()
|
||||
result = 31 * result + (artist.rawName?.lowercase() ?: MediaStore.UNKNOWN_STRING).hashCode()
|
||||
result = 31 * result + (date?.year ?: 0)
|
||||
return result
|
||||
}
|
||||
|
@ -262,7 +262,7 @@ data class Artist(
|
|||
}
|
||||
|
||||
override val id: Long
|
||||
get() = (rawName ?: MediaStore.UNKNOWN_STRING).hashCode().toLong()
|
||||
get() = (rawName?.lowercase() ?: MediaStore.UNKNOWN_STRING).hashCode().toLong()
|
||||
|
||||
override fun resolveName(context: Context) = rawName ?: context.getString(R.string.def_artist)
|
||||
|
||||
|
@ -283,7 +283,7 @@ data class Genre(override val rawName: String?, override val songs: List<Song>)
|
|||
get() = rawName
|
||||
|
||||
override val id: Long
|
||||
get() = (rawName ?: MediaStore.UNKNOWN_STRING).hashCode().toLong()
|
||||
get() = (rawName?.lowercase() ?: MediaStore.UNKNOWN_STRING).hashCode().toLong()
|
||||
|
||||
override fun resolveName(context: Context) = rawName ?: context.getString(R.string.def_genre)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue