Create lock before launching the coroutine,

return always a copy of the list and not the real one.
This commit is contained in:
tzugen 2022-04-21 20:24:43 +02:00
parent 1d236aa6e3
commit 827654c0c1
No known key found for this signature in database
GPG Key ID: 61E9C34BC10EC930
2 changed files with 3 additions and 3 deletions

View File

@ -77,7 +77,7 @@ class LegacyPlaylistManager : KoinComponent {
// Public facing playlist (immutable)
val playlist: List<DownloadFile>
get() = _playlist
get() = _playlist.toList()
@get:Synchronized
val playlistDuration: Long

View File

@ -43,8 +43,8 @@ class PlaybackStateSerializer : KoinComponent {
) {
if (!setup.get()) return
ioScope.launch {
if (lock.tryLock()) {
if (lock.tryLock()) {
ioScope.launch {
try {
serializeNow(songs, currentPlayingIndex, currentPlayingPosition)
} finally {