Rename ProjectConfigurator, restructure Projects workspace, retire MediaCollection naming
- Rename MediaConfig -> ProjectConfigurator throughout; drop the Parameters
tab/page; rename the Mounts tab to Projects and restructure it into three
sections: Central services, Main services, Third-party services
- Add a self-describe contract (GET /api/info returning name/tabs/mountTypes)
and a server-side discovery proxy (POST /api/discover-service) so adding a
main service only requires a URL
- Add ProjectConfigurator HA: multiple instances now sync their settings with
each other (GET /api/settings/export, POST /api/settings/sync, a periodic
background puller), last-write-wins per key by updated_at
- Add a generic, project-agnostic file-storage API on CarrierNode
(GET/POST/DELETE /api/mount/{project}/{type}[/*]) driven by the same
configured_mounts data the Projects workspace already writes, usable by any
registered project, not just the media family
- Add last_login_at tracking to the shared auth Store/User (schema, queries,
UpdateLastLogin) and surface it through the shared web-ui ManagedUser type
and UserManagement component
- Retire the "MediaCollection" name: Go module -> repos.gfranz.ch/Gabriel20xx/shared/media-backend,
binary -> mediabackend, session cookie default -> "session", media-webui
merged into webui, media-shared-assets renamed to legacy-assets and pruned
to the one file MediaDesktop still uses
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
07cf3308da
commit
ee59571552
126 files changed
+2880
-8542
No files matched your search
@@ -21,7 +21,7 @@ import (
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
|
||||
"mediacollection/internal/auth"
|
||||
"repos.gfranz.ch/Gabriel20xx/shared/media-backend/internal/auth"
|
||||
)
|
||||
|
||||
func (s *Server) mountToolsRoutes(r chi.Router) {
|
||||
@@ -298,7 +298,7 @@ func (s *Server) executeConversion(ctx context.Context, job WorkflowJob) (map[st
|
||||
if sourceName == "" {
|
||||
return nil, fmt.Errorf("converter input path is required")
|
||||
}
|
||||
source, cleanupSource, err := s.fetchWorkflowFileFromServant(ctx, sourceName)
|
||||
source, cleanupSource, err := s.fetchWorkflowFileFromCarrierNode(ctx, sourceName)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("converter input is not an allowed file: %w", err)
|
||||
}
|
||||
@@ -334,7 +334,7 @@ func (s *Server) executeConversion(ctx context.Context, job WorkflowJob) (map[st
|
||||
if err != nil || info.IsDir() {
|
||||
return nil, fmt.Errorf("ffmpeg did not produce an output file")
|
||||
}
|
||||
size, err := s.servantPushOutput(ctx, outputName, outputPath)
|
||||
size, err := s.carrierNodePushOutput(ctx, outputName, outputPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("converted output could not be stored: %w", err)
|
||||
}
|
||||
@@ -371,9 +371,9 @@ func (s *Server) executeDownload(ctx context.Context, job WorkflowJob) (map[stri
|
||||
return nil, fmt.Errorf("downloaded file is unavailable")
|
||||
}
|
||||
filename := filepath.Base(filePath)
|
||||
// Pushing through Servant's upload endpoint also catalogs the file into media/media_worker_jobs
|
||||
// (see servantRawUpload) - no separate indexMediaFile call needed here.
|
||||
if _, err := s.servantUploadDownload(ctx, filePath, filename); err != nil {
|
||||
// Pushing through CarrierNode's upload endpoint also catalogs the file into media/media_worker_jobs
|
||||
// (see carrierNodeRawUpload) - no separate indexMediaFile call needed here.
|
||||
if _, err := s.carrierNodeUploadDownload(ctx, filePath, filename); err != nil {
|
||||
return nil, fmt.Errorf("downloaded file could not be stored: %w", err)
|
||||
}
|
||||
_, _ = s.db.Exec(ctx, `INSERT INTO downloaded_media (source_url, tool, file_path, file_name, file_size_bytes, status, started_at, finished_at) VALUES ($1,'yt-dlp',$2,$3,$4,'completed',$5,NOW())`, sourceURL, filename, filename, info.Size(), job.CreatedAt)
|
||||
@@ -439,25 +439,25 @@ func firstString(values map[string]any, keys ...string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// workflowFileServantPaths mirrors the search order resolveWorkflowFile used to walk locally
|
||||
// (InputRoot, MediaRoots, DownloadsRoot, OutputRoot) but as Servant-side mount prefixes, since
|
||||
// workflowFileCarrierNodePaths mirrors the search order resolveWorkflowFile used to walk locally
|
||||
// (InputRoot, MediaRoots, DownloadsRoot, OutputRoot) but as CarrierNode-side mount prefixes, since
|
||||
// MediaTools no longer has any of those roots mounted on its own filesystem.
|
||||
var workflowFileServantPaths = []string{"/mount/inputs/", "/media/", "/media/downloads/", "/mount/generated/"}
|
||||
var workflowFileCarrierNodePaths = []string{"/mount/inputs/", "/media/", "/media/downloads/", "/mount/generated/"}
|
||||
|
||||
// fetchWorkflowFileFromServant locates a converter input under any of Servant's mounts and
|
||||
// fetchWorkflowFileFromCarrierNode locates a converter input under any of CarrierNode's mounts and
|
||||
// downloads it into an ephemeral scratch file for ffmpeg to read; the caller must invoke the
|
||||
// returned cleanup once done.
|
||||
func (s *Server) fetchWorkflowFileFromServant(ctx context.Context, value string) (string, func(), error) {
|
||||
func (s *Server) fetchWorkflowFileFromCarrierNode(ctx context.Context, value string) (string, func(), error) {
|
||||
value = strings.TrimSpace(value)
|
||||
if !safeRelative(value) {
|
||||
return "", nil, os.ErrNotExist
|
||||
}
|
||||
for _, prefix := range workflowFileServantPaths {
|
||||
servantPath := prefix + urlPath(value)
|
||||
if exists, _, _, err := s.probeServant(ctx, servantPath); err != nil || !exists {
|
||||
for _, prefix := range workflowFileCarrierNodePaths {
|
||||
carrierNodePath := prefix + urlPath(value)
|
||||
if exists, _, _, err := s.probeCarrierNode(ctx, carrierNodePath); err != nil || !exists {
|
||||
continue
|
||||
}
|
||||
return s.fetchServantToScratch(ctx, servantPath, filepath.Ext(value))
|
||||
return s.fetchCarrierNodeToScratch(ctx, carrierNodePath, filepath.Ext(value))
|
||||
}
|
||||
return "", nil, os.ErrNotExist
|
||||
}
|
||||
@@ -723,7 +723,7 @@ func (s *Server) uploadCopy(w http.ResponseWriter, r *http.Request) {
|
||||
if s.cfg.MaxUploadBytes > 0 {
|
||||
r.Body = http.MaxBytesReader(w, r.Body, s.cfg.MaxUploadBytes)
|
||||
}
|
||||
filename, size, err := s.saveMultipartUpload(r, s.servantPushCopy)
|
||||
filename, size, err := s.saveMultipartUpload(r, s.carrierNodePushCopy)
|
||||
if err != nil {
|
||||
writeError(w, http.StatusBadRequest, err.Error())
|
||||
return
|
||||
@@ -736,7 +736,7 @@ func (s *Server) toolUpload(w http.ResponseWriter, r *http.Request) {
|
||||
if s.cfg.MaxUploadBytes > 0 {
|
||||
r.Body = http.MaxBytesReader(w, r.Body, s.cfg.MaxUploadBytes)
|
||||
}
|
||||
filename, size, err := s.saveMultipartUpload(r, s.servantPushInput)
|
||||
filename, size, err := s.saveMultipartUpload(r, s.carrierNodePushInput)
|
||||
if err != nil {
|
||||
writeError(w, http.StatusBadRequest, err.Error())
|
||||
return
|
||||
@@ -815,7 +815,7 @@ func (s *Server) toolFile(w http.ResponseWriter, r *http.Request, mountPrefix st
|
||||
writeError(w, http.StatusNotFound, "file not found")
|
||||
return
|
||||
}
|
||||
s.proxyServant(w, r, mountPrefix+urlPath(relative))
|
||||
s.proxyCarrierNode(w, r, mountPrefix+urlPath(relative))
|
||||
}
|
||||
|
||||
func (s *Server) workflowList(w http.ResponseWriter, _ *http.Request) {
|
||||
@@ -895,13 +895,13 @@ func (s *Server) downloadWorkflowResult(w http.ResponseWriter, r *http.Request)
|
||||
writeError(w, http.StatusNotFound, "job result not found")
|
||||
return
|
||||
}
|
||||
servantPath := "/mount/generated/" + urlPath(filename)
|
||||
if exists, _, _, err := s.probeServant(r.Context(), servantPath); err != nil || !exists {
|
||||
carrierNodePath := "/mount/generated/" + urlPath(filename)
|
||||
if exists, _, _, err := s.probeCarrierNode(r.Context(), carrierNodePath); err != nil || !exists {
|
||||
writeError(w, http.StatusGone, "job result is no longer available")
|
||||
return
|
||||
}
|
||||
w.Header().Set("Content-Disposition", `attachment; filename="`+filepath.Base(filename)+`"`)
|
||||
s.proxyServant(w, r, servantPath)
|
||||
s.proxyCarrierNode(w, r, carrierNodePath)
|
||||
}
|
||||
|
||||
func scanWorkflowJob(row interface{ Scan(...any) error }) (WorkflowJob, error) {
|
||||
|
||||
Reference in new issue
Block a user