fix: make local development work out of the box
- library.example.yaml now uses relative ./media paths for local runs - clearer startup errors for missing roots and config files - ignore the local config/library.yaml override
This commit is contained in:
1 parent
f5e247e164
commit
af2a8bd35d
5 files changed
+31
-11
No files matched your search
@@ -11,6 +11,7 @@ build/
|
|||||||
# Local runtime data
|
# Local runtime data
|
||||||
data/
|
data/
|
||||||
media/
|
media/
|
||||||
|
config/library.yaml
|
||||||
config/users.yaml
|
config/users.yaml
|
||||||
*.db
|
*.db
|
||||||
*.db-shm
|
*.db-shm
|
||||||
|
|||||||
@@ -25,18 +25,20 @@ mkdir -p media/music media/longform
|
|||||||
library:
|
library:
|
||||||
folders:
|
folders:
|
||||||
- id: 1
|
- id: 1
|
||||||
name: "Alice - Music"
|
name: "Music"
|
||||||
type: music
|
type: music
|
||||||
path: /absolute/path/to/music/alice
|
path: ./media/music
|
||||||
- id: 10
|
- id: 10
|
||||||
name: "Audiobooks & Podcasts"
|
name: "Audiobooks & Podcasts"
|
||||||
type: longform
|
type: longform
|
||||||
path: /absolute/path/to/longform
|
path: ./media/longform
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The example file already uses these relative paths, so no edit is needed for local development. Relative paths are resolved from the working directory (`./gradlew run` uses the project root). For deployment, replace them with absolute paths such as `/mnt/media/music/alice` (see Section 6.1).
|
||||||
|
|
||||||
- `type: music` roots are assigned per user; `type: longform` roots are shared with every user.
|
- `type: music` roots are assigned per user; `type: longform` roots are shared with every user.
|
||||||
- `id` must be stable and unique (integers). It is part of song IDs, so do not renumber it after a scan.
|
- `id` must be stable and unique (integers). It is part of song IDs, so do not renumber it after a scan.
|
||||||
- Paths must exist and be readable, otherwise the server refuses to start.
|
- Paths must exist and be readable, otherwise the server refuses to start with a clear error naming the folder.
|
||||||
|
|
||||||
### 3. Configure users
|
### 3. Configure users
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,11 @@
|
|||||||
# Example library configuration. Mount the real file as a ConfigMap.
|
# Example library configuration.
|
||||||
|
#
|
||||||
|
# The paths below are relative to the working directory and are meant for local
|
||||||
|
# development: `./gradlew run` creates a `./media` tree after you run
|
||||||
|
# `mkdir -p media/music media/longform`.
|
||||||
|
#
|
||||||
|
# In Kubernetes the real file is mounted as a ConfigMap and should use absolute
|
||||||
|
# paths, e.g. /mnt/media/music/alice and /mnt/media/longform.
|
||||||
#
|
#
|
||||||
# Folder IDs are stable identifiers used by songs and users. Never reuse an ID
|
# Folder IDs are stable identifiers used by songs and users. Never reuse an ID
|
||||||
# for a different path.
|
# for a different path.
|
||||||
@@ -7,8 +14,8 @@ library:
|
|||||||
- id: 1
|
- id: 1
|
||||||
name: "Music"
|
name: "Music"
|
||||||
type: music
|
type: music
|
||||||
path: /mnt/media/music
|
path: ./media/music
|
||||||
- id: 10
|
- id: 10
|
||||||
name: "Audiobooks & Podcasts"
|
name: "Audiobooks & Podcasts"
|
||||||
type: longform
|
type: longform
|
||||||
path: /mnt/media/longform
|
path: ./media/longform
|
||||||
@@ -35,17 +35,24 @@ data class LibraryConfig(val folders: List<MusicFolder>) {
|
|||||||
fun validatePaths() {
|
fun validatePaths() {
|
||||||
folders.forEach { folder ->
|
folders.forEach { folder ->
|
||||||
require(Files.isDirectory(folder.path)) {
|
require(Files.isDirectory(folder.path)) {
|
||||||
"Library folder ${folder.id} (${folder.name}) is not a directory: ${folder.path}"
|
"Library folder ${folder.id} (${folder.name}) is not a directory: ${folder.path}. " +
|
||||||
|
"Create the directory or fix the path in the library config (LIBRARY_CONFIG). " +
|
||||||
|
"For local development, copy config/library.example.yaml and run " +
|
||||||
|
"`mkdir -p media/music media/longform`."
|
||||||
}
|
}
|
||||||
require(Files.isReadable(folder.path)) {
|
require(Files.isReadable(folder.path)) {
|
||||||
"Library folder ${folder.id} (${folder.name}) is not readable: ${folder.path}"
|
"Library folder ${folder.id} (${folder.name}) is not readable: ${folder.path}. " +
|
||||||
|
"Check the directory permissions."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun load(path: Path): LibraryConfig {
|
fun load(path: Path): LibraryConfig {
|
||||||
require(Files.isRegularFile(path)) { "Library config not found: $path" }
|
require(Files.isRegularFile(path)) {
|
||||||
|
"Library config not found: $path. Copy config/library.example.yaml to " +
|
||||||
|
"config/library.yaml or point LIBRARY_CONFIG at an existing file."
|
||||||
|
}
|
||||||
val text = Files.readString(path)
|
val text = Files.readString(path)
|
||||||
return parse(text)
|
return parse(text)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,10 @@ data class UsersConfig(val users: List<UserAccount>) {
|
|||||||
private val NAME_PATTERN = Regex("[A-Za-z0-9._-]{1,64}")
|
private val NAME_PATTERN = Regex("[A-Za-z0-9._-]{1,64}")
|
||||||
|
|
||||||
fun load(path: Path): UsersConfig {
|
fun load(path: Path): UsersConfig {
|
||||||
require(Files.isRegularFile(path)) { "Users file not found: $path" }
|
require(Files.isRegularFile(path)) {
|
||||||
|
"Users file not found: $path. Copy config/users.example.yaml to config/users.yaml " +
|
||||||
|
"or point USERS_FILE at the Vault-managed file."
|
||||||
|
}
|
||||||
val text = Files.readString(path)
|
val text = Files.readString(path)
|
||||||
return parse(text)
|
return parse(text)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user