mirror of
https://gitlab.com/ultrasonic/ultrasonic.git
synced 2025-04-25 13:12:16 +03:00
Fix a bug where newly added Artists were not cached correctly
This commit is contained in:
parent
fda746905d
commit
35a0dd761d
@ -18,6 +18,7 @@ import java.io.RandomAccessFile
|
||||
import org.koin.core.component.KoinComponent
|
||||
import org.koin.core.component.inject
|
||||
import org.moire.ultrasonic.data.ActiveServerProvider
|
||||
import org.moire.ultrasonic.domain.Artist
|
||||
import org.moire.ultrasonic.domain.MusicDirectory
|
||||
import org.moire.ultrasonic.service.MusicServiceFactory.getMusicService
|
||||
import org.moire.ultrasonic.subsonic.ImageLoaderProvider
|
||||
@ -200,6 +201,8 @@ class DownloadFile(
|
||||
}
|
||||
|
||||
private inner class DownloadTask : CancellableTask() {
|
||||
val musicService = getMusicService()
|
||||
|
||||
override fun execute() {
|
||||
var inputStream: InputStream? = null
|
||||
var outputStream: FileOutputStream? = null
|
||||
@ -222,8 +225,6 @@ class DownloadFile(
|
||||
return
|
||||
}
|
||||
|
||||
val musicService = getMusicService()
|
||||
|
||||
// Some devices seem to throw error on partial file which doesn't exist
|
||||
val needsDownloading: Boolean
|
||||
val duration = song.duration
|
||||
@ -314,8 +315,22 @@ class DownloadFile(
|
||||
// Once the albums are cached in db, we should retrieve the album,
|
||||
// and then cache the album artist.
|
||||
if (artistId.isEmpty()) return
|
||||
val artist = activeServerProvider.getActiveMetaDatabase().artistsDao().get(artistId)
|
||||
activeServerProvider.offlineMetaDatabase.artistsDao().insert(artist)
|
||||
var artist: Artist? =
|
||||
activeServerProvider.getActiveMetaDatabase().artistsDao().get(artistId)
|
||||
|
||||
// If we are downloading a new album, and the user has not visited the Artists list
|
||||
// recently, then the artist won't be in the database.
|
||||
if (artist == null) {
|
||||
val artists: List<Artist> = musicService.getArtists(true)
|
||||
artist = artists.find {
|
||||
it.id == artistId
|
||||
}
|
||||
}
|
||||
|
||||
// If we have found an artist, catch it.
|
||||
if (artist != null) {
|
||||
activeServerProvider.offlineMetaDatabase.artistsDao().insert(artist)
|
||||
}
|
||||
}
|
||||
|
||||
private fun downloadAndSaveCoverArt() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user