Compare commits
11 Commits
8802755300
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| bbb7afce3f | |||
| 0aaa29b1e2 | |||
| 3e2f0ca681 | |||
| 6646ba4c54 | |||
| 9779205be0 | |||
| c178cf1bf9 | |||
| 1b9397234a | |||
| b5206af920 | |||
| 7b25ceb1af | |||
| 1650afa030 | |||
| 57788fe43e |
15
.woodpecker.yaml
Normal file
15
.woodpecker.yaml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
when:
|
||||||
|
branch: main
|
||||||
|
event:
|
||||||
|
- push
|
||||||
|
- manual
|
||||||
|
steps:
|
||||||
|
- name: build
|
||||||
|
image: woodpeckerci/plugin-docker-buildx
|
||||||
|
settings:
|
||||||
|
repo: git.halfbinary.net/${CI_REPO_OWNER}/prettyplayerapi
|
||||||
|
registry: git.halfbinary.net
|
||||||
|
tags: ${CI_PIPELINE_NUMBER}
|
||||||
|
username: ${CI_REPO_OWNER}
|
||||||
|
password:
|
||||||
|
from_secret: docker_password
|
||||||
27
Dockerfile
Normal file
27
Dockerfile
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
FROM amazoncorretto:21-alpine-jdk as build
|
||||||
|
|
||||||
|
LABEL maintainer="Alex Arbit <aarbit@gmail.com>"
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY build.gradle.kts .
|
||||||
|
COPY gradlew .
|
||||||
|
COPY gradlew.bat .
|
||||||
|
COPY settings.gradle.kts .
|
||||||
|
COPY gradle ./gradle
|
||||||
|
COPY src ./src
|
||||||
|
|
||||||
|
RUN apk --no-cache add gradle
|
||||||
|
|
||||||
|
RUN gradle bootJar
|
||||||
|
|
||||||
|
RUN ls -al
|
||||||
|
RUN ls -al /
|
||||||
|
|
||||||
|
FROM amazoncorretto:21-alpine-jdk
|
||||||
|
|
||||||
|
COPY --from=build /app/build/libs/*.jar app.jar
|
||||||
|
RUN ls -al
|
||||||
|
EXPOSE 8080
|
||||||
|
|
||||||
|
ENTRYPOINT ["java","-jar","app.jar"]
|
||||||
@@ -32,6 +32,7 @@ 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)
|
||||||
@@ -40,6 +41,7 @@ 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()
|
||||||
@@ -57,9 +59,11 @@ 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()
|
||||||
@@ -79,9 +83,11 @@ 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()
|
||||||
@@ -89,6 +95,7 @@ class AlbumCacheService(
|
|||||||
launch { getAndWriteAlbumImageFile(it, folderHash, folderPath) }
|
launch { getAndWriteAlbumImageFile(it, folderHash, folderPath) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
logger.debug { "...completed caching album art." }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createAlbumArtRootDir() {
|
fun createAlbumArtRootDir() {
|
||||||
|
|||||||
@@ -21,19 +21,14 @@ class StartupService(
|
|||||||
@Async
|
@Async
|
||||||
@EventListener(ApplicationStartedEvent::class)
|
@EventListener(ApplicationStartedEvent::class)
|
||||||
suspend fun onStartup() {
|
suspend fun onStartup() {
|
||||||
if (withContext(ioDispatcher) {
|
val cacheType = if (withContext(ioDispatcher) { albumRepository.count() } == 0L) {
|
||||||
albumRepository.count()
|
CacheType.ALL}
|
||||||
} == 0L) {
|
else {
|
||||||
coroutineScope {
|
CacheType.NEW
|
||||||
launch {
|
}
|
||||||
albumCacheService.cacheAlbums(CacheType.ALL)
|
coroutineScope {
|
||||||
}
|
launch {
|
||||||
}
|
albumCacheService.cacheAlbums(cacheType)
|
||||||
} else {
|
|
||||||
coroutineScope {
|
|
||||||
launch {
|
|
||||||
albumCacheService.cacheAlbums(CacheType.NEW)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user