feat: config.toml wird automatisch angelegt wenn fehlend
CI / backend-tests (push) Successful in 8s
Docker images / version (push) Successful in 2s
CI / docker (push) Successful in 5s
Docker images / backend (push) Successful in 5s
Docker images / frontend (push) Successful in 5s

This commit is contained in:
loki committed 2026-10-04 13:31:08 +02:00
1 parent 06094bfe04
commit 4b915d3b52
4 files changed
+66

No files matched your search

+4
View File
@@ -76,6 +76,10 @@ docker compose -f docker-compose.image.yml pull
docker compose -f docker-compose.image.yml up -d
```
Frischer Server in drei Schritten: Volumes mounten (werden ggf. angelegt),
starten — fehlende `config.toml` erzeugt das Backend automatisch —, dann ARL
auf der Einstellungen-Seite eintragen. Fertig.
Compose-Auszug (`docker-compose.image.yml` — fertige Images, kein Bauen):
```yaml
+27
View File
@@ -5,15 +5,42 @@ from pathlib import Path
from app.core import settings
def _ensure_config_exists() -> bool:
"""Create a default config.toml if missing. Returns True if created."""
import logging
from streamrip.config import set_user_defaults
p = Path(settings.CONFIG_PATH)
if p.exists():
return False
p.parent.mkdir(parents=True, exist_ok=True)
set_user_defaults(str(p))
# Point the download folder at our environment (e.g. /downloads in Docker).
try:
from tomlkit.api import dumps as toml_dumps
from tomlkit.api import parse as toml_parse
doc = toml_parse(p.read_text())
doc["downloads"]["folder"] = str(Path(settings.DOWNLOAD_DIR).expanduser())
p.write_text(toml_dumps(doc))
except Exception as e:
logging.getLogger("streamrip-ui").warning("could not set download folder: %s", e)
return True
def _load_config():
"""Load streamrip Config with DB paths rewritten to the config dir.
The mounted config.toml may contain host-absolute DB paths
(e.g. /home/lokman/...) that don't exist inside the container.
Rewriting them to the config dir keeps history working everywhere.
A missing config.toml is created from streamrip defaults (ARL stays
empty and must be added via the UI).
"""
from streamrip.config import Config
_ensure_config_exists()
config = Config(settings.CONFIG_PATH)
cfg_dir = Path(settings.CONFIG_PATH).parent
try:
+33
View File
@@ -0,0 +1,33 @@
from app.core import settings
def test_missing_config_is_created_with_defaults(tmp_path, monkeypatch):
from app.services.streamrip_service import _load_config
cfg = tmp_path / "sub" / "config.toml"
dl = tmp_path / "dl"
dl.mkdir()
monkeypatch.setattr(settings, "CONFIG_PATH", str(cfg))
monkeypatch.setattr(settings, "DOWNLOAD_DIR", str(dl))
config = _load_config()
assert cfg.exists()
assert config.session.downloads.folder == str(dl)
# ARL empty -> user must add it via UI
assert config.session.deezer.arl == ""
def test_existing_config_is_not_touched(tmp_path, monkeypatch):
from app.services.streamrip_service import _load_config
cfg = tmp_path / "config.toml"
cfg.write_text('[downloads]\nfolder = "/keep/me"\n')
monkeypatch.setattr(settings, "CONFIG_PATH", str(cfg))
# minimal file: _load_config must not overwrite, only streamrip decides
before = cfg.read_text()
try:
_load_config()
except Exception:
pass # streamrip may reject incomplete files - must not have overwritten
assert cfg.read_text() == before
+2
View File
@@ -56,6 +56,8 @@ lokal Single-User **ohne Login** (bewusst, nur Heimnetz — nicht ins Internet s
- `~/.local/bin/rip` (pipx-Shim) ist kaputt — irrelevant, Library-Import genutzt.
- DB-Pfade aus gemounteter `config.toml` zeigen auf Host-Pfade → Service biegt sie
auf das Config-Verzeichnis um (`_load_config`).
- Fehlende `config.toml` wird automatisch aus streamrip-Defaults angelegt
(`_ensure_config_exists`, Ordner = `STREAMRIP_DOWNLOAD_DIR`); ARL danach per UI.
- Next-14-Fallen: keine `use(params)`-Promise-Params; keine fremden Exporte aus
`page.tsx` (z. B. `sortByDate` → `app/lib/sort.ts`); `public/`-Copy im
Standalone-Dockerfile nötig; Healthcheck mit `127.0.0.1` statt `localhost`