Skip to content

Commit 20bc06f

Browse files
nabacoclaude
andcommitted
fix(system-config): re-read mediamtx.yml on each request (v0.6.2)
Configuration tab was showing stale yml because the file was parsed once at startup and the result cached on Server. Now Parse runs per request so on-disk edits — including our own UpsertPath writes — are visible immediately. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 36c2bdb commit 20bc06f

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.6.1
1+
0.6.2

internal/api/handlers_system.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package api
22

33
import (
44
"net/http"
5+
6+
"mediamtx-ui/internal/parser"
57
)
68

79
type systemInfoResponse struct {
@@ -40,14 +42,23 @@ func (s *Server) handleSystemInfo(w http.ResponseWriter, r *http.Request) {
4042
}
4143

4244
func (s *Server) handleSystemConfig(w http.ResponseWriter, r *http.Request) {
43-
if s.configFile == nil || !s.configFile.Available {
45+
// Re-read on every request so edits (including ones we wrote via
46+
// parser.UpsertPath) show up without a server restart. Falls back to
47+
// the path the parser resolved at startup when no explicit ConfigPath
48+
// is set in config.
49+
path := s.cfg.MediaMTX.ConfigPath
50+
if path == "" && s.configFile != nil {
51+
path = s.configFile.ResolvedPath
52+
}
53+
cur := parser.Parse(path)
54+
if cur == nil || !cur.Available {
4455
jsonOK(w, systemConfigResponse{Available: false})
4556
return
4657
}
4758
jsonOK(w, systemConfigResponse{
4859
Available: true,
49-
ResolvedPath: s.configFile.ResolvedPath,
50-
RawYAML: s.configFile.RawYAML,
60+
ResolvedPath: cur.ResolvedPath,
61+
RawYAML: cur.RawYAML,
5162
})
5263
}
5364

0 commit comments

Comments
 (0)