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