Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: write the segment join list under a real temp directory (#11149)

Adam Eivyc638ba1c4751
diff --git a/server/services/htmlComposition/encode.segments.test.js b/server/services/htmlComposition/encode.segments.test.js
index 2219fa772b..02122f616a 100644
--- a/server/services/htmlComposition/encode.segments.test.js
+++ b/server/services/htmlComposition/encode.segments.test.js
@@ -18,32 +18,41 @@ describe('encodeCompositionSegments', () => {
const progress = [];
const joins = [];
const first = page('first');
- await encodeCompositionSegments(first, contract, '/tmp/out.mp4', {
- workers: 3, offsetSec: 30,
- openPage: async () => { const p = page(`extra${opened.length}`); opened.push(p); return p; },
- videoFilterAt: (offsetSec) => `grade@${offsetSec}`,
- encode: async (p, c, path, options) => {
- calls.push({ page: p.name, frames: Math.round(c.durationSec * c.fps), path, offsetSec: options.offsetSec, continuous: options.continuous, followed: options.followed, filter: options.videoFilter });
- options.onProgress(1, { frame: Math.round(c.durationSec * c.fps) });
- return {};
- },
- locateFfmpeg: async () => 'ffmpeg',
- runFfmpeg: async ({ args }) => { joins.push(args); return { ok: true }; },
- onProgress: (fraction) => progress.push(fraction),
- });
- calls.sort((a, b) => a.offsetSec - b.offsetSec);
- expect(calls.map(({ frames, offsetSec, continuous, followed, filter }) => ({ frames, offsetSec, continuous, followed, filter }))).toEqual([
- { frames: 480, offsetSec: 30, continuous: false, followed: true, filter: 'grade@30' },
- { frames: 480, offsetSec: 50, continuous: true, followed: true, filter: 'grade@50' },
- { frames: 480, offsetSec: 70, continuous: true, followed: false, filter: 'grade@70' },
- ]);
- // The caller's page draws the first segment and stays open; the extra pages close.
- expect(calls[0].page).toBe('first');
- expect(first.closed).toBe(0);
- expect(opened.map((p) => p.closed)).toEqual([1, 1]);
- expect(progress.at(-1)).toBe(1);
- expect(joins).toHaveLength(1);
- expect(joins[0]).toEqual(expect.arrayContaining(['-f', 'concat', '-c', 'copy', '/tmp/out.mp4']));
+ // The join writes `<output>.parts.txt` beside the output. `/tmp` is not a
+ // directory on Windows (it becomes `<drive>:\tmp`), so the parent must be
+ // a real temp directory or writeFile fails with ENOENT.
+ const dir = mkdtempSync(join(tmpdir(), 'encode-segments-'));
+ const output = join(dir, 'out.mp4');
+ try {
+ await encodeCompositionSegments(first, contract, output, {
+ workers: 3, offsetSec: 30,
+ openPage: async () => { const p = page(`extra${opened.length}`); opened.push(p); return p; },
+ videoFilterAt: (offsetSec) => `grade@${offsetSec}`,
+ encode: async (p, c, path, options) => {
+ calls.push({ page: p.name, frames: Math.round(c.durationSec * c.fps), path, offsetSec: options.offsetSec, continuous: options.continuous, followed: options.followed, filter: options.videoFilter });
+ options.onProgress(1, { frame: Math.round(c.durationSec * c.fps) });
+ return {};
+ },
+ locateFfmpeg: async () => 'ffmpeg',
+ runFfmpeg: async ({ args }) => { joins.push(args); return { ok: true }; },
+ onProgress: (fraction) => progress.push(fraction),
+ });
+ calls.sort((a, b) => a.offsetSec - b.offsetSec);
+ expect(calls.map(({ frames, offsetSec, continuous, followed, filter }) => ({ frames, offsetSec, continuous, followed, filter }))).toEqual([
+ { frames: 480, offsetSec: 30, continuous: false, followed: true, filter: 'grade@30' },
+ { frames: 480, offsetSec: 50, continuous: true, followed: true, filter: 'grade@50' },
+ { frames: 480, offsetSec: 70, continuous: true, followed: false, filter: 'grade@70' },
+ ]);
+ // The caller's page draws the first segment and stays open; the extra pages close.
+ expect(calls[0].page).toBe('first');
+ expect(first.closed).toBe(0);
+ expect(opened.map((p) => p.closed)).toEqual([1, 1]);
+ expect(progress.at(-1)).toBe(1);
+ expect(joins).toHaveLength(1);
+ expect(joins[0]).toEqual(expect.arrayContaining(['-f', 'concat', '-c', 'copy', output]));
+ } finally {
+ rmSync(dir, { recursive: true, force: true });
+ }
});
it('renders a short window in one pass on the caller\'s page', async () => {