Compare commits
No commits in common. "0aaa29b1e2ed5e49c6c025e6b9e71dc40e0904a4" and "6646ba4c543ab63fa516521221a28fb4b54886d5" have entirely different histories.
0aaa29b1e2
...
6646ba4c54
@ -32,7 +32,6 @@ class AlbumCacheService(
|
||||
it.isFile && it.extension == "mp3" && it.name.startsWith("01.")
|
||||
}
|
||||
.toList()
|
||||
logger.info { "Album count: ${fileList.count()}" }
|
||||
when (type) {
|
||||
CacheType.ART -> cacheArt(fileList)
|
||||
CacheType.NEW -> cacheNew(fileList)
|
||||
@ -41,7 +40,6 @@ class AlbumCacheService(
|
||||
}
|
||||
|
||||
suspend fun cacheAll(fileList: List<File>) {
|
||||
logger.debug { "Caching all albums..." }
|
||||
fileList.forEach {
|
||||
val mp3File = Mp3File(it)
|
||||
val folderPath = it.parentFile.toPath()
|
||||
@ -59,11 +57,9 @@ class AlbumCacheService(
|
||||
)
|
||||
)
|
||||
}
|
||||
logger.debug { "...completed caching all albums." }
|
||||
}
|
||||
|
||||
suspend fun cacheNew(fileList: List<File>) {
|
||||
logger.debug { "Caching new albums..." }
|
||||
fileList.forEach {
|
||||
val folderPath = it.parentFile.toPath()
|
||||
val folderHash = folderPath.name.hashCode().toString()
|
||||
@ -83,11 +79,9 @@ class AlbumCacheService(
|
||||
)
|
||||
}
|
||||
}
|
||||
logger.debug { "...completed caching new albums." }
|
||||
}
|
||||
|
||||
suspend fun cacheArt(fileList: List<File>) {
|
||||
logger.debug { "Caching album art..." }
|
||||
fileList.forEach {
|
||||
val folderPath = it.parentFile.toPath()
|
||||
val folderHash = folderPath.name.hashCode().toString()
|
||||
@ -95,7 +89,6 @@ class AlbumCacheService(
|
||||
launch { getAndWriteAlbumImageFile(it, folderHash, folderPath) }
|
||||
}
|
||||
}
|
||||
logger.debug { "...completed caching album art." }
|
||||
}
|
||||
|
||||
fun createAlbumArtRootDir() {
|
||||
|
||||
@ -21,14 +21,19 @@ class StartupService(
|
||||
@Async
|
||||
@EventListener(ApplicationStartedEvent::class)
|
||||
suspend fun onStartup() {
|
||||
val cacheType = if (withContext(ioDispatcher) { albumRepository.count() } == 0L) {
|
||||
CacheType.ALL}
|
||||
else {
|
||||
CacheType.NEW
|
||||
}
|
||||
coroutineScope {
|
||||
launch {
|
||||
albumCacheService.cacheAlbums(cacheType)
|
||||
if (withContext(ioDispatcher) {
|
||||
albumRepository.count()
|
||||
} == 0L) {
|
||||
coroutineScope {
|
||||
launch {
|
||||
albumCacheService.cacheAlbums(CacheType.ALL)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
coroutineScope {
|
||||
launch {
|
||||
albumCacheService.cacheAlbums(CacheType.NEW)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user