fix(config): wire DataDir from yaml/env through to playlists service
Slice 1 of M7 #352 added Server.DataDir but left it un-populated — the playlist cover-collage writer would have used "" as the relative path root in production, writing to the current working directory. - Add Storage.DataDir to Config (yaml: storage.data_dir, env: SMARTMUSIC_STORAGE_DATA_DIR), defaulting to "./data". - server.New takes the data dir as a parameter; main.go threads it. - main.go MkdirAll's the directory at startup so the playlist cover writer doesn't fail on first use with a missing parent. - config.example.yaml documents the new section. Existing internal/server/server_test.go constructs Server directly without server.New, so no test fixture changes needed for that file.
This commit is contained in:
+11
-1
@@ -97,9 +97,19 @@ func run() error {
|
||||
lidarrReconciler := lidarrrequests.NewReconciler(pool, lidarrCfg, logger.With("component", "lidarr"))
|
||||
go lidarrReconciler.Run(ctx)
|
||||
|
||||
// Ensure DataDir exists before any service tries to write into it.
|
||||
// Best-effort: log + continue on failure; the playlist cover writer
|
||||
// will surface a clearer error at first use.
|
||||
if cfg.Storage.DataDir != "" {
|
||||
if err := os.MkdirAll(cfg.Storage.DataDir, 0o755); err != nil {
|
||||
logger.Warn("data_dir create failed; cached artifacts may not persist",
|
||||
"path", cfg.Storage.DataDir, "err", err)
|
||||
}
|
||||
}
|
||||
|
||||
srv := server.New(logger, pool, scanner, subsonic.Config{
|
||||
AllowPlaintextPassword: cfg.Subsonic.AllowPlaintextPassword,
|
||||
}, cfg.Events, cfg.Recommendation)
|
||||
}, cfg.Events, cfg.Recommendation, cfg.Storage.DataDir)
|
||||
httpServer := &http.Server{
|
||||
Addr: cfg.Server.Address,
|
||||
Handler: srv.Router(),
|
||||
|
||||
Reference in New Issue
Block a user