Revert to Docker-only source paths, fix config validation, improve transcoding info

- handlers_sources.go: revert to relative paths rooted at /media (remove standalone absolute-path mode)
- settings.html: remove manual path input, restore auto-loading source tree from /media
- config.go: remove filesystem existence checks from Validate() — paths may be temporarily unavailable
- transcoder.go: always specify fps in ffmpeg args when MaxFPS is set, preserving source fps if lower than limit
- copier.go: include source codec/format and target codec/format in transcoding task message

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-21 21:28:28 +03:00
parent e885e49647
commit 0a17d11bd1
5 changed files with 91 additions and 196 deletions

View File

@@ -3,6 +3,7 @@ package api
import (
"errors"
"net/http"
"net/url"
"os"
"path/filepath"
"sort"
@@ -10,19 +11,20 @@ import (
)
func (s *Server) handleSources(w http.ResponseWriter, r *http.Request) {
absPath, err := normalizeSourcePathQuery(r.URL.Query().Get("path"))
relPath, err := normalizeSourcePath(r.URL.Query().Get("path"))
if err != nil {
jsonErr(w, http.StatusBadRequest, err.Error())
return
}
if absPath == "" {
jsonOK(w, map[string]any{"path": "", "items": []map[string]string{}})
return
absPath := s.deps.Config.MediaPath
if relPath != "" {
absPath = filepath.Join(absPath, relPath)
}
entries, err := os.ReadDir(absPath)
if err != nil {
jsonOK(w, map[string]any{"path": absPath, "items": []map[string]string{}})
jsonOK(w, map[string]any{"path": relPath, "items": []map[string]string{}})
return
}
@@ -36,10 +38,13 @@ func (s *Server) handleSources(w http.ResponseWriter, r *http.Request) {
if !e.IsDir() || strings.HasPrefix(e.Name(), ".") {
continue
}
childPath := filepath.Join(absPath, e.Name())
childPath := e.Name()
if relPath != "" {
childPath = filepath.Join(relPath, childPath)
}
items = append(items, item{
Name: e.Name(),
Path: childPath,
Path: filepath.ToSlash(childPath),
})
}
@@ -48,18 +53,26 @@ func (s *Server) handleSources(w http.ResponseWriter, r *http.Request) {
})
jsonOK(w, map[string]any{
"path": absPath,
"path": relPath,
"items": items,
})
}
func normalizeSourcePathQuery(raw string) (string, error) {
func normalizeSourcePath(raw string) (string, error) {
raw, _ = url.QueryUnescape(raw)
raw = strings.TrimSpace(raw)
raw = filepath.ToSlash(raw)
raw = strings.TrimPrefix(raw, "/")
if raw == "" || raw == "." {
return "", nil
}
clean := filepath.Clean(raw)
if !filepath.IsAbs(clean) {
clean = filepath.ToSlash(clean)
if clean == "." {
return "", nil
}
if clean == ".." || strings.HasPrefix(clean, "../") {
return "", errors.New("invalid source path")
}
return clean, nil