converge everything into one data folder

This commit is contained in:
legop3
2026-09-13 22:10:15 -04:00
parent b199f45eb2
commit 17b1404157
13 changed files with 860 additions and 40 deletions
@@ -1,8 +1,8 @@
// Replay Builder Pipeline
// Purpose: Assembles selected buffered segments into final replay output video with optional sidebar.
// Scope: Owns concat/probe/layout/transcode pipeline and returns replay buffer plus source usage metadata.
const os = require('os');
const path = require('path');
const { resolveRuntimePath } = require('../../helpers/dataPaths');
const { getActiveDrivers } = require('../turnService');
const { getNickname } = require('../nicknameService');
const { getRecentMessages } = require('../chatService');
@@ -124,7 +124,15 @@ function createReplayBuilder({ execFileAsync, fsp, ensureDir, renderSidebarVideo
durationMs: BUILD_DURATION_MS,
});
const resolvedTitle = sanitizeReplayTitle(title, resolveDefaultReplayTitle(requester, sources));
const tmpDir = await fsp.mkdtemp(path.join(os.tmpdir(), 'mrr-replay-v2-'));
/*
A replay build is disposable, but every intermediate concat list, pinned
segment, and ffmpeg output is created on the server's behalf. Create a
unique workspace below SERVER_DATA_DIR so the application never spills
those writes into the host-wide temporary directory.
*/
const buildRoot = resolveRuntimePath('replay-builds');
await ensureDir(buildRoot);
const tmpDir = await fsp.mkdtemp(path.join(buildRoot, 'build-'));
try {
const usedSources = [];
@@ -4,11 +4,11 @@
const { execFile } = require('child_process');
const EventEmitter = require('events');
const fsp = require('fs/promises');
const os = require('os');
const path = require('path');
const { promisify } = require('util');
const logger = require('../../globals/logger').child('roomCameraReplay');
const { resolveRuntimePath } = require('../../helpers/dataPaths');
const execFileAsync = promisify(execFile);
@@ -118,7 +118,15 @@ async function buildRoomCameraReplayVideo({ cameraId = null } = {}, { getRoomCam
});
if (!cameraEntries.length) throw new Error('No camera frames available yet');
const tmpDir = await fsp.mkdtemp(path.join(os.tmpdir(), 'rover-replay-'));
/*
Hundreds of frame images can be produced for one room-camera replay. They
are temporary, but the Node application owns them, so both the workspace
and final intermediate video stay under the configured data root until the
existing finally block removes them.
*/
const buildRoot = resolveRuntimePath('room-camera-replay-builds');
await fsp.mkdir(buildRoot, { recursive: true });
const tmpDir = await fsp.mkdtemp(path.join(buildRoot, 'build-'));
try {
const firstFramePaths = [];
for (let i = 0; i < cameraEntries.length; i += 1) {