diff --git a/src/main/kotlin/net/halfbinary/prettyplayerapi/service/StartupService.kt b/src/main/kotlin/net/halfbinary/prettyplayerapi/service/StartupService.kt index 964e17b..698cf14 100644 --- a/src/main/kotlin/net/halfbinary/prettyplayerapi/service/StartupService.kt +++ b/src/main/kotlin/net/halfbinary/prettyplayerapi/service/StartupService.kt @@ -21,19 +21,14 @@ class StartupService( @Async @EventListener(ApplicationStartedEvent::class) suspend fun onStartup() { - if (withContext(ioDispatcher) { - albumRepository.count() - } == 0L) { - coroutineScope { - launch { - albumCacheService.cacheAlbums(CacheType.ALL) - } - } - } else { - coroutineScope { - launch { - albumCacheService.cacheAlbums(CacheType.NEW) - } + val cacheType = if (withContext(ioDispatcher) { albumRepository.count() } == 0L) { + CacheType.ALL} + else { + CacheType.NEW + } + coroutineScope { + launch { + albumCacheService.cacheAlbums(cacheType) } } }