From b0e77ef3cc8ba9ec298a1635316d21d98b865a5a Mon Sep 17 00:00:00 2001 From: ranke96 Date: Wed, 15 Jul 2026 22:19:33 +0800 Subject: [PATCH] Fix mediainfo failing on non-ascii filenames (empty child env + missing locale) exec()/startJob() replaced the child process environment entirely, so mediainfo ran with no PATH and no locale. Under the C/POSIX locale mediainfo exits 1 on any filename containing non-ascii characters, which left duration permanently "Unknown" and caused every channel list request to retry mediainfo for each affected VOD. - Execute.ts: spawn with the parent env, overlaying any custom vars - Dockerfile: set LANG/LC_ALL=C.UTF-8 Co-Authored-By: Claude Sonnet 5 --- Dockerfile | 4 ++++ server/src/Helpers/Execute.ts | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4b6a6004..80cc9f64 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,6 +14,10 @@ ENV VITE_IS_DEV=${IS_DEV} ENV BUILD_DATE=${BUILD_DATE} ENV VITE_BUILD_DATE=${BUILD_DATE} +# utf-8 locale so child processes (mediainfo etc) can open non-ascii filenames +ENV LANG=C.UTF-8 +ENV LC_ALL=C.UTF-8 + # system packages #RUN apk --no-cache add \ # gcc g++ libc-dev git curl \ diff --git a/server/src/Helpers/Execute.ts b/server/src/Helpers/Execute.ts index 20b9de0d..29810031 100644 --- a/server/src/Helpers/Execute.ts +++ b/server/src/Helpers/Execute.ts @@ -372,12 +372,15 @@ export function exec( ticker?: (source: "stdout" | "stderr", data: string) => void, progressFunction?: (log: string) => number | undefined ): Promise { + // inherit the parent environment (PATH, locale, etc) instead of replacing it; + // an empty env made mediainfo unable to open non-ascii filenames + const spawnEnv = { ...process.env, ...env }; return new Promise((resolve, reject) => { const stdout: string[] = []; const stderr: string[] = []; const process = spawn(bin, args || [], { - env: env, + env: spawnEnv, }); process.on("error", (err) => { @@ -547,7 +550,9 @@ export function startJob( args: string[], env: Record = {} ): Job | false { - const envs = Object.keys(env).length > 0 ? env : process.env; + // inherit the parent environment (PATH, locale, etc) and overlay the custom values, + // so child processes can still open non-ascii filenames + const envs = { ...process.env, ...env }; const stdout: string[] = []; const stderr: string[] = [];