Add self-info endpoint for ProjectConfigurator discovery, sync shared updates
Lint / Lint (push) Successful in 1m5s
Tests / Go backend (push) Successful in 46s
Docker / Docker Build & Push (push) Failing after 2m1s
Tests / Dashboard checks (push) Successful in 49s

GET /api/info reports name/tabs/mount types (empty - state lives in Postgres,
no shared file mounts) so ProjectConfigurator's Projects workspace can
register this instance from just a URL.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Gabriel20xxandClaude Sonnet 5 committed 2026-09-04 15:07:02 +02:00
1 parent 557a61b4ee
commit bbf5d8bb05
126 files changed
+2897 -8542

No files matched your search

@@ -18,7 +18,7 @@ import (
"github.com/go-chi/chi/v5"
"mediacollection/internal/config"
"repos.gfranz.ch/Gabriel20xx/shared/media-backend/internal/config"
)
func (s *Server) mountAnalyzerRoutes(r chi.Router) {
@@ -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. MediaServant unreachable)
// the UI, so a discover/metadata/cleanup run that fails fast (e.g. CarrierNode unreachable)
// is reported here instead of just looking like it silently reverted to idle.
lastError := firstNonEmpty(scan.LastError, clear.LastError)
@@ -925,7 +925,7 @@ func (s *Server) createThumbnail(ctx context.Context, candidate thumbnailCandida
return "", fmt.Errorf("unsupported media type for %s", sourcePath)
}
sourceScratch, cleanupSource, err := s.fetchServantToScratch(ctx, "/media/"+urlPath(sourcePath), filepath.Ext(sourcePath))
sourceScratch, cleanupSource, err := s.fetchCarrierNodeToScratch(ctx, "/media/"+urlPath(sourcePath), filepath.Ext(sourcePath))
if err != nil {
return "", fmt.Errorf("fetch %s: %w", sourcePath, err)
}
@@ -972,7 +972,7 @@ func (s *Server) createThumbnail(ctx context.Context, candidate thumbnailCandida
if err != nil || info.Size() == 0 {
return "", fmt.Errorf("ffmpeg produced no thumbnail")
}
size, err := s.servantPushThumbnail(ctx, thumbnailID, temporaryPath)
size, err := s.carrierNodePushThumbnail(ctx, thumbnailID, temporaryPath)
if err != nil {
return "", fmt.Errorf("store thumbnail: %w", err)
}
@@ -981,11 +981,11 @@ func (s *Server) createThumbnail(ctx context.Context, candidate thumbnailCandida
VALUES ($1, $2, $3)
ON CONFLICT (source_path) DO NOTHING`, thumbnailID, sourcePath, size)
if err != nil {
_ = s.servantDeleteThumbnail(ctx, thumbnailID)
_ = s.carrierNodeDeleteThumbnail(ctx, thumbnailID)
return "", fmt.Errorf("save thumbnail record: %w", err)
}
if insertTag.RowsAffected() == 0 {
_ = s.servantDeleteThumbnail(ctx, thumbnailID)
_ = s.carrierNodeDeleteThumbnail(ctx, thumbnailID)
return "", nil
}
return thumbnailID, nil
@@ -1017,7 +1017,7 @@ func (s *Server) analyzerThumb(w http.ResponseWriter, r *http.Request) {
writeError(w, http.StatusBadRequest, "invalid thumbnail id")
return
}
s.proxyServant(w, r, "/thumbnails/"+id+".jpg")
s.proxyCarrierNode(w, r, "/thumbnails/"+id+".jpg")
}
func (s *Server) analyzerAction(w http.ResponseWriter, r *http.Request, action string) {
@@ -1255,7 +1255,7 @@ func (s *Server) cleanupStaleMedia() {
s.scan.FilesIndexed++
s.scanMu.Unlock()
if exists, _, _, err := s.probeServant(ctx, "/media/"+urlPath(item.filePath)); err == nil && exists {
if exists, _, _, err := s.probeCarrierNode(ctx, "/media/"+urlPath(item.filePath)); err == nil && exists {
continue // file still exists on disk - nothing stale about this one
}
removed++
@@ -1264,7 +1264,7 @@ func (s *Server) cleanupStaleMedia() {
var thumbnailID string
if s.db.QueryRow(ctx, `SELECT id FROM thumbnails WHERE source_path = $1`, item.filePath).Scan(&thumbnailID) == nil {
_ = s.servantDeleteThumbnail(ctx, thumbnailID)
_ = s.carrierNodeDeleteThumbnail(ctx, thumbnailID)
_, _ = s.db.Exec(ctx, `DELETE FROM thumbnails WHERE id = $1`, thumbnailID)
}
_, _ = s.db.Exec(ctx, `DELETE FROM media_worker_jobs WHERE file_path = $1`, item.filePath)
@@ -1296,19 +1296,19 @@ func (s *Server) scanMediaFiles(selectedTypes map[string]bool) {
}()
batch := time.Now().UTC().Format("20060102T150405.000000000Z")
files, err := s.servantListFiles(ctx, "", false, 0)
files, err := s.carrierNodeListFiles(ctx, "", false, 0)
if err != nil {
log.Printf("analyzer: discovery scan: failed to list files: %v", err)
runErr = fmt.Errorf("could not reach MediaServant to list files: %w", err)
runErr = fmt.Errorf("could not reach CarrierNode to list files: %w", err)
return
}
// MediaServant reachable but reporting an empty library is otherwise indistinguishable from
// CarrierNode 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: MediaServant reported zero files")
runErr = fmt.Errorf("MediaServant reported no files under its configured media root(s) - check the Mounts settings in MediaConfig")
log.Printf("analyzer: discovery scan: CarrierNode reported zero files")
runErr = fmt.Errorf("CarrierNode reported no files under its configured media root(s) - check the Projects settings in ProjectConfigurator")
return
}
for _, file := range files {
@@ -1345,9 +1345,9 @@ func (s *Server) indexMediaFile(ctx context.Context, key string, size int64, mod
var width, height int
var probeErr error
var hasFunscript bool
// Servant has the storage mounted and can probe/stat locally; every other service goes
// through Servant's HTTP API instead of touching MediaRoots itself (see servant_client.go).
if s.cfg.Service == config.Servant {
// CarrierNode has the storage mounted and can probe/stat locally; every other service goes
// through CarrierNode's HTTP API instead of touching MediaRoots itself (see carriernode_client.go).
if s.cfg.Service == config.CarrierNode {
fullPath, resolveErr := s.resolveAnyMediaPath(ctx, key)
if metadataAttempted && resolveErr == nil {
var probe map[string]any
@@ -1361,8 +1361,8 @@ func (s *Server) indexMediaFile(ctx context.Context, key string, size int64, mod
hasFunscript = s.pipelineStageEnabled(ctx, "funscript", "metadata") && resolveErr == nil && hasFunscriptSidecar(fullPath)
} else {
if metadataAttempted {
var probe servantProbeResult
probe, probeErr = s.servantProbe(ctx, key)
var probe carrierNodeProbeResult
probe, probeErr = s.carrierNodeProbe(ctx, key)
duration = nullableInt64(probe.DurationMs)
width, height = probe.Width, probe.Height
}
@@ -1447,7 +1447,7 @@ func (s *Server) refreshMetadataForTypes(selectedTypes map[string]bool) {
s.scan.FilesIndexed++
s.scanMu.Unlock()
if exists, _, _, err := s.probeServant(ctx, "/media/"+urlPath(item.filePath)); err != nil || !exists {
if exists, _, _, err := s.probeCarrierNode(ctx, "/media/"+urlPath(item.filePath)); err != nil || !exists {
continue
}
@@ -1463,7 +1463,7 @@ func (s *Server) refreshMetadataForTypes(selectedTypes map[string]bool) {
if !s.pipelineStageEnabled(ctx, item.mediaType, "metadata") {
continue
}
probe, probeErr := s.servantProbe(ctx, item.filePath)
probe, probeErr := s.carrierNodeProbe(ctx, item.filePath)
if probeErr != nil {
_, _ = s.db.Exec(ctx, `UPDATE media_worker_jobs SET metadata_status='error', metadata_error=$2 WHERE file_path=$1`, item.filePath, probeErr.Error())
continue
@@ -1501,11 +1501,11 @@ func hasFunscriptSidecar(filePath string) bool {
}
// funscriptSidecarExists is hasFunscriptSidecar for callers without local filesystem access
// (MediaAnalyzer) - it checks for the sidecar on Servant instead of statting a local path.
// (MediaAnalyzer) - it checks for the sidecar on CarrierNode 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"} {
if exists, _, _, err := s.probeServant(ctx, "/media/"+urlPath(candidate)); err == nil && exists {
if exists, _, _, err := s.probeCarrierNode(ctx, "/media/"+urlPath(candidate)); err == nil && exists {
return true
}
}
@@ -1747,7 +1747,7 @@ func (s *Server) deleteThumbnailsForType(ctx context.Context, mediaType string)
}
rows.Close()
for _, id := range ids {
_ = s.servantDeleteThumbnail(ctx, id)
_ = s.carrierNodeDeleteThumbnail(ctx, id)
}
if len(ids) > 0 {
if _, err := s.db.Exec(ctx, `DELETE FROM thumbnails WHERE id = ANY($1::uuid[])`, ids); err != nil {
@@ -1779,7 +1779,7 @@ func (s *Server) clearFunscriptFlag(ctx context.Context) error {
// picked back up fresh on the next discovery run.
func (s *Server) clearPipelineSelection(w http.ResponseWriter, r *http.Request) {
var payload struct {
Types []string `json:"types"`
Types []string `json:"types"`
Stages []string `json:"stages"`
}
if err := decodeRequestJSON(r, &payload); err != nil {