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 @Dao
internal interface CacheReadDao { internal interface CacheReadDao {
@Query("SELECT * FROM CachedSongData") @Query("SELECT * FROM CachedSongData") suspend fun selectAllSongs(): List<CachedSongData>
suspend fun selectAllSongs(): List<CachedSongData>
} }
@Dao @Dao
@@ -37,11 +37,11 @@ import org.oxycblt.musikr.tag.parse.ParsedTags
class DBCache private constructor(private val readDao: CacheReadDao) : Cache { class DBCache private constructor(private val readDao: CacheReadDao) : Cache {
private var mapping: Map<Uri, CachedSongData>? = null private var mapping: Map<Uri, CachedSongData>? = null
private val mappingLock = Mutex() private val mappingLock = Mutex()
override suspend fun read(file: File): CacheResult { override suspend fun read(file: File): CacheResult {
mappingLock.lock() mappingLock.lock()
val currentMapping = mapping ?: readDao.selectAllSongs().associateBy { it.uri }.also { val currentMapping =
mapping = it mapping ?: readDao.selectAllSongs().associateBy { it.uri }.also { mapping = it }
}
mappingLock.unlock() mappingLock.unlock()
val dbSong = currentMapping[file.uri] ?: return CacheResult.Miss(file) val dbSong = currentMapping[file.uri] ?: return CacheResult.Miss(file)
if (dbSong.modifiedMs != file.modifiedMs) { if (dbSong.modifiedMs != file.modifiedMs) {