Fix media-backend/media-webui: re-copy from post-revert MediaCollection
The original MediaEngine extraction (later folded into this repo) had been done BEFORE the owner's decision to revert the MediaViewer/Forge/ etc. rename, and was never re-extracted afterward like the other 7 service repos were - it silently carried stale renamed-era text (e.g. 'Porter' instead of 'MediaServant') into Go doc comments, WebUI prose, project-icons.json, and app-config.ts. Re-copied both directories fresh from the current (correctly reverted) MediaCollection/backend and MediaCollection/WebUI, then re-applied the go.mod replace-directive fix and re-added SECURITY_AUDIT.md (also newly migrated from MediaCollection root - a real deployment security checklist that would otherwise have been lost when MediaCollection is deleted). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
acde180086
commit
38a349eb52
20 files changed
+74
-55
No files matched your search
@@ -85,7 +85,7 @@ func Load() (*Config, error) {
|
||||
MediaRoots: roots,
|
||||
InputRoot: filepath.Clean(envOr("INPUT_DIR", "./input")),
|
||||
CopyRoot: filepath.Clean(envOr("UPLOAD_COPY_DIR", "./copy")),
|
||||
WorkflowsRoot: filepath.Clean(envOr("WORKFLOWS_DIR", filepath.Join("..", "Forge", "public", "workflows"))),
|
||||
WorkflowsRoot: filepath.Clean(envOr("WORKFLOWS_DIR", filepath.Join("..", "MediaTools", "public", "workflows"))),
|
||||
ThumbnailRoot: filepath.Clean(envOr("THUMBNAIL_DIR", "./thumbnails")),
|
||||
OutputRoot: filepath.Clean(envOr("OUTPUT_DIR", "./output")),
|
||||
DownloadsRoot: filepath.Clean(envOr("DOWNLOADS_DIR", "./downloads")),
|
||||
|
||||
@@ -311,7 +311,7 @@ CREATE INDEX IF NOT EXISTS media_analysis_tasks_status_idx ON media_analysis_tas
|
||||
-- to make repeated analysis runs idempotent instead of piling up duplicate tag rows.
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS media_tags_ai_tag_unique ON media_tags (media_key, tag) WHERE user_id IS NULL;
|
||||
|
||||
-- Speeds up the Lookout dashboard/pipelines/history/live-status queries: analyzerStats and
|
||||
-- Speeds up the MediaAnalyzer dashboard/pipelines/history/live-status queries: analyzerStats and
|
||||
-- analyzerPipelineBreakdown group active media by type (and join it against thumbnails), and
|
||||
-- analyzerHistory sorts media_worker_jobs by queued_at with no status filter, none of which the
|
||||
-- existing media/media_worker_jobs indexes above actually cover.
|
||||
|
||||
@@ -213,7 +213,7 @@ func (s *Server) configuredMounts(ctx context.Context) map[string][]mountEntry {
|
||||
}
|
||||
|
||||
// mountMappings returns each project's mount configuration as project -> mount type -> path(s),
|
||||
// the shape /mounts/resolve and /mounts/paths (and Porter's own "Mount health" panel via
|
||||
// the shape /mounts/resolve and /mounts/paths (and MediaServant's own "Mount health" panel via
|
||||
// /mounts) expect. configured_mounts is the live source and wins per-project when present;
|
||||
// mounts_path_mappings is an older format nothing has written since the Mounts workspace moved
|
||||
// to configured_mounts, kept only so a deployment that hasn't resaved its mounts since upgrading
|
||||
@@ -275,8 +275,8 @@ func (s *Server) mountMappings(ctx context.Context) map[string]any {
|
||||
// opposed to a project-specific working directory like "downloads", "generated",
|
||||
// "thumbnails", or "models", which have their own dedicated Root config fields instead and
|
||||
// are deliberately left out here. A path is entered under whichever project's tab happens to
|
||||
// need it (Lookout's "images"/"videos"/"audios", Playhouse/Marquee's "media", ...)
|
||||
// but they're all describing locations Porter itself has to walk, since it's the only
|
||||
// need it (MediaAnalyzer's "images"/"videos"/"audios", MediaViewer/MediaKiosk's "media", ...)
|
||||
// but they're all describing locations MediaServant itself has to walk, since it's the only
|
||||
// service with the volume mounted - see effectiveMediaRoots.
|
||||
var mediaLibraryMountTypes = map[string]bool{
|
||||
"media": true, "images": true, "videos": true, "audios": true, "funscripts": true,
|
||||
@@ -575,7 +575,7 @@ func (s *Server) writeServantFiles(w http.ResponseWriter, r *http.Request, recen
|
||||
if recent {
|
||||
sort.Slice(files, func(i, j int) bool { return files[i].Mtime > files[j].Mtime })
|
||||
}
|
||||
// Internal callers (e.g. Lookout discovery) need to list an entire real-sized library
|
||||
// Internal callers (e.g. MediaAnalyzer discovery) need to list an entire real-sized library
|
||||
// in one pass; the public 1000-item cap stays in place for anyone without the shared secret.
|
||||
maxLimit := 1000
|
||||
if s.cfg.InternalServiceSecret != "" && r.Header.Get("X-Internal-Auth") == s.cfg.InternalServiceSecret {
|
||||
@@ -785,7 +785,7 @@ func (s *Server) servantStore(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
// resolveStoreFile is Servant's own local-filesystem lookup for /api/store, which catalogs a
|
||||
// file Forge already pushed into one of Servant's mounts (InputRoot, MediaRoots,
|
||||
// file MediaTools already pushed into one of Servant's mounts (InputRoot, MediaRoots,
|
||||
// DownloadsRoot, OutputRoot) - unlike everything else in this file, it's called with a path that
|
||||
// isn't necessarily under MediaRoots, so it can't just use resolveMediaPath.
|
||||
func (s *Server) resolveStoreFile(value string) (string, error) {
|
||||
|
||||
@@ -147,7 +147,7 @@ func (s *Server) analyzerStatus(w http.ResponseWriter, r *http.Request) {
|
||||
running := clear.Running || scan.Running || thumbnail.Running || analysis.Running || processing > 0
|
||||
// scan/clear have no dedicated status endpoint of their own (thumbnail/analysis do, via
|
||||
// generate/status and analyze/status) - this is the only place their LastError ever reaches
|
||||
// the UI, so a discover/metadata/cleanup run that fails fast (e.g. Porter unreachable)
|
||||
// the UI, so a discover/metadata/cleanup run that fails fast (e.g. MediaServant unreachable)
|
||||
// is reported here instead of just looking like it silently reverted to idle.
|
||||
lastError := firstNonEmpty(scan.LastError, clear.LastError)
|
||||
|
||||
@@ -1299,16 +1299,16 @@ func (s *Server) scanMediaFiles(selectedTypes map[string]bool) {
|
||||
files, err := s.servantListFiles(ctx, "", false, 0)
|
||||
if err != nil {
|
||||
log.Printf("analyzer: discovery scan: failed to list files: %v", err)
|
||||
runErr = fmt.Errorf("could not reach Porter to list files: %w", err)
|
||||
runErr = fmt.Errorf("could not reach MediaServant to list files: %w", err)
|
||||
return
|
||||
}
|
||||
// Porter reachable but reporting an empty library is otherwise indistinguishable from
|
||||
// MediaServant reachable but reporting an empty library is otherwise indistinguishable from
|
||||
// a successful no-op run - every existing file re-indexes (and increments FilesIndexed) on
|
||||
// every scan, so a real library can never legitimately finish at zero. Flag it instead of
|
||||
// letting "discovery started" silently revert to idle with nothing to show for it.
|
||||
if len(files) == 0 {
|
||||
log.Printf("analyzer: discovery scan: Porter reported zero files")
|
||||
runErr = fmt.Errorf("Porter reported no files under its configured media root(s) - check the Mounts settings in MediaConfig")
|
||||
log.Printf("analyzer: discovery scan: MediaServant reported zero files")
|
||||
runErr = fmt.Errorf("MediaServant reported no files under its configured media root(s) - check the Mounts settings in MediaConfig")
|
||||
return
|
||||
}
|
||||
for _, file := range files {
|
||||
@@ -1501,7 +1501,7 @@ func hasFunscriptSidecar(filePath string) bool {
|
||||
}
|
||||
|
||||
// funscriptSidecarExists is hasFunscriptSidecar for callers without local filesystem access
|
||||
// (Lookout) - it checks for the sidecar on Servant instead of statting a local path.
|
||||
// (MediaAnalyzer) - it checks for the sidecar on Servant instead of statting a local path.
|
||||
func (s *Server) funscriptSidecarExists(ctx context.Context, key string) bool {
|
||||
base := strings.TrimSuffix(key, filepath.Ext(key))
|
||||
for _, candidate := range []string{base + ".funscript", base + ".json"} {
|
||||
|
||||
@@ -433,7 +433,7 @@ type analysisSidecarRequest struct {
|
||||
}
|
||||
|
||||
// callAnalyzerModelsService calls the AnalyzerModels sidecar (a separate process in the same
|
||||
// container, not baked into this binary - see ANALYZER_MODELS_URL and Lookout/Dockerfile),
|
||||
// container, not baked into this binary - see ANALYZER_MODELS_URL and MediaAnalyzer/Dockerfile),
|
||||
// the same way executeGeneration already calls out to ComfyUI for image generation. Video frames
|
||||
// are analyzed through the image endpoint since by the time this runs the video has already been
|
||||
// reduced to a still frame.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package server
|
||||
|
||||
// Servant client: every non-Servant service serves and stores media by calling Porter's
|
||||
// Servant client: every non-Servant service serves and stores media by calling MediaServant's
|
||||
// HTTP API through the helpers in this file instead of touching MediaRoots/ThumbnailRoot/
|
||||
// OutputRoot/DownloadsRoot/InputRoot/CopyRoot locally. Servant's own handlers keep using those
|
||||
// roots directly (see media.go, admin_storage.go) - this file is never called from Servant's
|
||||
|
||||
@@ -129,7 +129,7 @@ type scanState struct {
|
||||
Total int64
|
||||
StartedAt *time.Time
|
||||
// LastError survives the end-of-run reset (unlike every other field here) so a run that
|
||||
// failed fast - e.g. Porter unreachable - doesn't just look like it silently reverted
|
||||
// failed fast - e.g. MediaServant unreachable - doesn't just look like it silently reverted
|
||||
// to idle; analyzerStatus reports it until the next run overwrites or clears it.
|
||||
LastError string
|
||||
}
|
||||
|
||||
@@ -441,7 +441,7 @@ func firstString(values map[string]any, keys ...string) string {
|
||||
|
||||
// workflowFileServantPaths mirrors the search order resolveWorkflowFile used to walk locally
|
||||
// (InputRoot, MediaRoots, DownloadsRoot, OutputRoot) but as Servant-side mount prefixes, since
|
||||
// Forge no longer has any of those roots mounted on its own filesystem.
|
||||
// MediaTools no longer has any of those roots mounted on its own filesystem.
|
||||
var workflowFileServantPaths = []string{"/mount/inputs/", "/media/", "/media/downloads/", "/mount/generated/"}
|
||||
|
||||
// fetchWorkflowFileFromServant locates a converter input under any of Servant's mounts and
|
||||
|
||||
Reference in new issue
Block a user