Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit 04f04d0dbb6858878d624b93fb28dbf5ec639062
parent f8153d3f33282ccf43aa700b7d3378de90731747
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Mon,  2 Nov 2026 16:01:09 -0500

umtool trailer: a cancelled cut (the Trailer page's Cancel signals the job) removes its half-made file before it exits

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
Mumtool/docs/report-video.md | 3++-
Mumtool/report-to-video/trailer.mjs | 41+++++++++++++++++++++++++++++++----------
2 files changed, 33 insertions(+), 11 deletions(-)

diff --git a/umtool/docs/report-video.md b/umtool/docs/report-video.md @@ -1403,7 +1403,8 @@ bench over one beat. Its in/out handles and nudge keys work on the master's fram writes the clip's source seconds. Each beat gets a verdict (`confirmed`, or `note`). Every write goes through the one writer and leaves an undo point (`U`, **Undo**, `trailer-beats … undo`). **Cut the trailer** runs `umtool trailer --reel` as a job on umtool's runner (the heavy slot, its -log, Cancel), and the file then plays on the page with its local path. A reel whose take has no +log, Cancel), and the file then plays on the page with its local path. A cancelled cut leaves no +half-made file: it is written beside the output and renamed only when the encode is done. A reel whose take has no master says so and links the Takes page to render one. Nothing renders on its own. ## Montages (`render.montage`) diff --git a/umtool/report-to-video/trailer.mjs b/umtool/report-to-video/trailer.mjs @@ -65,6 +65,7 @@ // this module, so the umtool app can import it without the gate in its bundle. import { execFile } from "node:child_process"; +import { rmSync } from "node:fs"; import { mkdir, readFile, readdir, rename, rm, writeFile } from "node:fs/promises"; import path from "node:path"; import { promisify } from "node:util"; @@ -677,17 +678,37 @@ export async function makeTrailer({ const tmp = path.join(path.dirname(outPath), `.${path.basename(outPath, ".mp4")}.${process.pid}.tmp.mp4`); argv[argv.length - 1] = tmp; let encodeSeconds = null; - await slot(async () => { - const t0 = now(); - try { - await run(argv); - await rename(tmp, outPath); - } catch (err) { - await rm(tmp, { force: true }); - throw err; - } - encodeSeconds = r3((now() - t0) / 1000); + // Cancelled (the Trailer page's Cancel signals the job's process group): the + // half-made file goes with it. Exits as the signal would when nothing else + // here listens for it. + const onSignal = ["SIGTERM", "SIGINT", "SIGHUP"].map((sig) => { + const alone = process.listenerCount(sig) === 0; + const h = () => { + try { + rmSync(tmp, { force: true }); + } catch { + // gone already + } + if (alone) process.exit(128 + (sig === "SIGINT" ? 2 : sig === "SIGHUP" ? 1 : 15)); + }; + process.once(sig, h); + return /** @type {const} */ ([sig, h]); }); + try { + await slot(async () => { + const t0 = now(); + try { + await run(argv); + await rename(tmp, outPath); + } catch (err) { + await rm(tmp, { force: true }); + throw err; + } + encodeSeconds = r3((now() - t0) / 1000); + }); + } finally { + for (const [sig, h] of onSignal) process.off(sig, h); + } record.builtAt = new Date(now()).toISOString(); record.encodeSeconds = encodeSeconds; record.out = outPath;