musikr: reformat

This commit is contained in:
Alexander Capehart
2025-07-04 17:28:58 -06:00
parent e0c959649a
commit 0eb6ba1765
2 changed files with 4 additions and 5 deletions
@@ -53,8 +53,7 @@ internal abstract class CacheDatabase : RoomDatabase() {
@Dao
internal interface CacheReadDao {
@Query("SELECT * FROM CachedSongData")
suspend fun selectAllSongs(): List<CachedSongData>
@Query("SELECT * FROM CachedSongData") suspend fun selectAllSongs(): List<CachedSongData>
}
@Dao
@@ -37,11 +37,11 @@ import org.oxycblt.musikr.tag.parse.ParsedTags
class DBCache private constructor(private val readDao: CacheReadDao) : Cache {
private var mapping: Map<Uri, CachedSongData>? = null
private val mappingLock = Mutex()
override suspend fun read(file: File): CacheResult {
mappingLock.lock()
val currentMapping = mapping ?: readDao.selectAllSongs().associateBy { it.uri }.also {
mapping = it
}
val currentMapping =
mapping ?: readDao.selectAllSongs().associateBy { it.uri }.also { mapping = it }
mappingLock.unlock()
val dbSong = currentMapping[file.uri] ?: return CacheResult.Miss(file)
if (dbSong.modifiedMs != file.modifiedMs) {