feat: extend media library controls and playback
Security / Secrets (gitleaks) (push) Successful in 1m49s
Security / Code (Semgrep) (push) Successful in 2m41s
Security / Dependencies (Trivy) (push) Successful in 1m9s
Docker / Docker Build & Push (push) Successful in 8m48s

- Add safe CarrierNode media deletion and rating support
- Count tag suggestions across visible, processed media
- Support muted autoplay in MediaPlayer
This commit is contained in:
Gabriel20xx committed 2026-11-13 19:23:02 +01:00
1 parent 5d9e3063c5
commit 0c4dc3aacb
5 files changed
+161 -4

No files matched your search

@@ -467,6 +467,47 @@ func (c *Client) DeleteMountFile(ctx context.Context, project, mountType, relati
return nil
}
// DeleteMedia removes one library file from the primary CarrierNode. carrierNodePath is the
// "/media/..." request path the caller probed, so the delete targets the same file the probe
// found. It reports whether CarrierNode removed a file: a 404 is a clean "not there" and returns
// false with a nil error, so a caller can tell a removal apart from a file that was already gone.
func (c *Client) DeleteMedia(ctx context.Context, carrierNodePath string) (bool, error) {
if !validMediaRequestPath(carrierNodePath) {
return false, fmt.Errorf("invalid media path")
}
request, err := c.newRequest(ctx, c.primaryBaseURL(ctx), http.MethodDelete, carrierNodePath, nil)
if err != nil {
return false, err
}
response, err := httpClient.Do(request)
if err != nil {
return false, err
}
defer response.Body.Close()
switch {
case response.StatusCode == http.StatusNotFound:
return false, nil
case response.StatusCode >= 400:
return false, fmt.Errorf("carriernode media delete failed: %s", response.Status)
}
return true, nil
}
// validMediaRequestPath accepts only a /media/ request path with no ".." segment after
// unescaping, so a delete cannot name a path outside the media route.
func validMediaRequestPath(carrierNodePath string) bool {
if !strings.HasPrefix(carrierNodePath, "/media/") {
return false
}
for _, segment := range strings.Split(carrierNodePath, "/") {
decoded, err := url.PathUnescape(segment)
if err != nil || decoded == ".." {
return false
}
}
return true
}
// ThumbnailMountType is the mount type ProjectConfigurator configures for a project's
// generated thumbnails. Each thumbnail is one "<id>.jpg" file under that mount.
const ThumbnailMountType = "thumbnails"