Skip to content

A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.

TypeScript fluxerfluxerapp

feat(rexctl): check that the media proxy can write temp files (#3756)

Hampusbac94f8cebc9
diff --git a/fluxer_rexctl/internal/checks/checks.go b/fluxer_rexctl/internal/checks/checks.go
index 663b38f36..4f00d75d3 100644
--- a/fluxer_rexctl/internal/checks/checks.go
+++ b/fluxer_rexctl/internal/checks/checks.go
@@ -107,6 +107,7 @@ var order = []string{
"certificate",
"discovery",
"app-proxy-discovery",
+ "media-proxy-spool",
"postgres-password",
"postgres-scram",
"livekit-ip",
diff --git a/fluxer_rexctl/internal/checks/media_proxy_spool.go b/fluxer_rexctl/internal/checks/media_proxy_spool.go
new file mode 100644
index 000000000..148caa4af
--- /dev/null
+++ b/fluxer_rexctl/internal/checks/media_proxy_spool.go
@@ -0,0 +1,40 @@
+// SPDX-License-Identifier: AGPL-3.0-or-later
+
+package checks
+
+import (
+ "context"
+ "io"
+
+ "github.com/fluxerapp/fluxer/fluxer_rexctl/internal/engine"
+)
+
+const (
+ mediaProxySpoolDir = `d="${FLUXER_MEDIA_PROXY_UPLOAD_RELAY_SPOOL_DIR:-${TMPDIR:-/tmp}}"`
+ mediaProxySpoolProbe = mediaProxySpoolDir + `; f="$(mktemp -p "$d")" && rm -f "$f"`
+ mediaProxySpoolRepair = mediaProxySpoolDir + `; mkdir -p "$d" && chmod 1777 "$d"`
+)
+
+func init() {
+ Register(Check{ID: "media-proxy-spool", Phases: Installed, Run: runMediaProxySpool, Fix: fixMediaProxySpool, SafeFix: true})
+}
+
+func runMediaProxySpool(ctx context.Context, e *Env) Result {
+ if e.Instance == nil || !e.running(ctx, "media-proxy") {
+ return skip("")
+ }
+ out, err := e.exec(ctx, "media-proxy", "", "sh", "-c", mediaProxySpoolProbe)
+ if err == nil {
+ return pass("The media proxy can write its temporary files.")
+ }
+ r := fixable(fail("The media proxy can't write its temporary files, so uploads from the desktop app fail.", "Run rexctl doctor --fix to make its temporary folder writable."))
+ r.Details = []string{out}
+ return r
+}
+
+func fixMediaProxySpool(ctx context.Context, e *Env) error {
+ if e.Project == nil {
+ return errNoProject
+ }
+ return e.Project.Exec(ctx, "media-proxy", engine.ExecOptions{User: "0", Stdout: io.Discard, Stderr: io.Discard}, "sh", "-c", mediaProxySpoolRepair)
+}