musikr: reformat
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user