Compare commits

..

No commits in common. "0aaa29b1e2ed5e49c6c025e6b9e71dc40e0904a4" and "6646ba4c543ab63fa516521221a28fb4b54886d5" have entirely different histories.

2 changed files with 13 additions and 15 deletions

View File

@ -32,7 +32,6 @@ class AlbumCacheService(
it.isFile && it.extension == "mp3" && it.name.startsWith("01.") it.isFile && it.extension == "mp3" && it.name.startsWith("01.")
} }
.toList() .toList()
logger.info { "Album count: ${fileList.count()}" }
when (type) { when (type) {
CacheType.ART -> cacheArt(fileList) CacheType.ART -> cacheArt(fileList)
CacheType.NEW -> cacheNew(fileList) CacheType.NEW -> cacheNew(fileList)
@ -41,7 +40,6 @@ class AlbumCacheService(
} }
suspend fun cacheAll(fileList: List<File>) { suspend fun cacheAll(fileList: List<File>) {
logger.debug { "Caching all albums..." }
fileList.forEach { fileList.forEach {
val mp3File = Mp3File(it) val mp3File = Mp3File(it)
val folderPath = it.parentFile.toPath() val folderPath = it.parentFile.toPath()
@ -59,11 +57,9 @@ class AlbumCacheService(
) )
) )
} }
logger.debug { "...completed caching all albums." }
} }
suspend fun cacheNew(fileList: List<File>) { suspend fun cacheNew(fileList: List<File>) {
logger.debug { "Caching new albums..." }
fileList.forEach { fileList.forEach {
val folderPath = it.parentFile.toPath() val folderPath = it.parentFile.toPath()
val folderHash = folderPath.name.hashCode().toString() val folderHash = folderPath.name.hashCode().toString()
@ -83,11 +79,9 @@ class AlbumCacheService(
) )
} }
} }
logger.debug { "...completed caching new albums." }
} }
suspend fun cacheArt(fileList: List<File>) { suspend fun cacheArt(fileList: List<File>) {
logger.debug { "Caching album art..." }
fileList.forEach { fileList.forEach {
val folderPath = it.parentFile.toPath() val folderPath = it.parentFile.toPath()
val folderHash = folderPath.name.hashCode().toString() val folderHash = folderPath.name.hashCode().toString()
@ -95,7 +89,6 @@ class AlbumCacheService(
launch { getAndWriteAlbumImageFile(it, folderHash, folderPath) } launch { getAndWriteAlbumImageFile(it, folderHash, folderPath) }
} }
} }
logger.debug { "...completed caching album art." }
} }
fun createAlbumArtRootDir() { fun createAlbumArtRootDir() {

View File

@ -21,14 +21,19 @@ class StartupService(
@Async @Async
@EventListener(ApplicationStartedEvent::class) @EventListener(ApplicationStartedEvent::class)
suspend fun onStartup() { suspend fun onStartup() {
val cacheType = if (withContext(ioDispatcher) { albumRepository.count() } == 0L) { if (withContext(ioDispatcher) {
CacheType.ALL} albumRepository.count()
else { } == 0L) {
CacheType.NEW coroutineScope {
} launch {
coroutineScope { albumCacheService.cacheAlbums(CacheType.ALL)
launch { }
albumCacheService.cacheAlbums(cacheType) }
} else {
coroutineScope {
launch {
albumCacheService.cacheAlbums(CacheType.NEW)
}
} }
} }
} }