Archilyzer · Source

archilyzer

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

commit 92561aa1d0a1c88ae971109300539c010c6e7cf9
parent 3a72d4456a38182b2006f5be65b5d006df3b3803
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Thu, 22 Oct 2026 15:52:30 -0400

live capture: the corpus's default saved-video store is made when missing (an override or a dangling link is still refused); the e2e's locators exact

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

Diffstat:
Mcommon/controller/landMedia.test.ts | 14++++++++++++++
Mcommon/controller/landMedia.ts | 28++++++++++++++++++++++++----
Mcommon/controller/recordLive.ts | 5++---
Meditor/e2e/live-capture.spec.ts | 6+++---
4 files changed, 43 insertions(+), 10 deletions(-)

diff --git a/common/controller/landMedia.test.ts b/common/controller/landMedia.test.ts @@ -218,6 +218,20 @@ test("import by url: one metadata pass makes the record under the URL id", async assert.match(archive, /^RumbleEmbed v8embed$/m); }); +test("the store's root: the corpus default is made when missing; an override or a dangling link is refused", async () => { + const { ensureStoreRoot } = await import("./landMedia"); + const { symlink } = await import("node:fs/promises"); + const base = path.join(ROOT, "roots"); + await mkdir(base, { recursive: true }); + const def = path.join(base, "saved-videos"); + await ensureStoreRoot({ savedVideosDir: def }, def, "x"); + assert.ok((await stat(def)).isDirectory()); + await assert.rejects(ensureStoreRoot({ savedVideosDir: def }, path.join(base, "elsewhere"), "nothing landed"), /is not there \(is its drive mounted\?\) — nothing landed/); + const dangling = path.join(base, "moved-store"); + await symlink(path.join(base, "unmounted", "saved-videos"), dangling); + await assert.rejects(ensureStoreRoot({ savedVideosDir: dangling }, dangling, "x"), /is not there/); +}); + test("the hand-off never lifts a pause, and says what takes the video", () => { const base = { workersPaused: false, laneEnabled: true, laneHeld: false, ruleCoversChannel: true, channelPaused: false, hasTranscript: false, transcribeJob: false }; assert.match(transcriptionHandoffLines(base)[0]!, /lane's rules take this channel/); diff --git a/common/controller/landMedia.ts b/common/controller/landMedia.ts @@ -33,7 +33,7 @@ // plus a margin free. import path from "node:path"; -import { appendFile, mkdir, readFile, readdir, rename, rm, stat } from "node:fs/promises"; +import { appendFile, lstat, mkdir, readFile, readdir, rename, rm, stat } from "node:fs/promises"; import { copyFileHashed } from "../lib/zipReader"; import { execa } from "execa"; import type { AudioFormat, ChannelConfig } from "../lib/channelConfig"; @@ -134,6 +134,28 @@ async function isDir(p: string): Promise<boolean> { return stat(p).then((s) => s.isDirectory(), () => false); } +// THE STORE'S ROOT, OR WHY NOT. A root that is there is used. The corpus's own +// default (`transcripts/saved-videos`) that was never made is made — one +// directory, beside the corpus — as the first persist would make it. Anything +// else missing is refused: a channel's override root on another drive, or a +// relocated store whose link dangles, is an unmounted drive, and a mkdir there +// would fill the root filesystem. +export async function ensureStoreRoot( + paths: Pick<Paths, "savedVideosDir">, + storeRoot: string, + what: string, +): Promise<void> { + if (await isDir(storeRoot)) return; + const present = await lstat(storeRoot).then(() => true, () => false); + if (!present && path.resolve(storeRoot) === path.resolve(paths.savedVideosDir) && (await isDir(path.dirname(storeRoot)))) { + await mkdir(storeRoot).catch((err: NodeJS.ErrnoException) => { + if (err.code !== "EEXIST") throw err; + }); + return; + } + throw new Error(`the saved-video store ${storeRoot} is not there (is its drive mounted?) — ${what}`); +} + function within(child: string, parent: string): boolean { const rel = path.relative(parent, child); return rel !== "" && !rel.startsWith("..") && !path.isAbsolute(rel); @@ -271,9 +293,7 @@ export async function landMediaFile(opts: LandMediaOpts): Promise<LandMediaResul let containerPath: string | null = pointer ? savedVideoPath(pointer) : null; let moved = false; if (kept === "new") { - if (!(await isDir(storeRoot))) { - throw new Error(`the saved-video store ${storeRoot} is not there (is its drive mounted?) — nothing landed`); - } + await ensureStoreRoot(opts.paths, storeRoot, "nothing landed"); await assertSavedVideosStoreWritable(opts.paths, storeDir); const free = await (opts.deps?.freeBytes ?? getFreeBytes)(storeRoot); if (free < st.size + LAND_MEDIA_DISK_MARGIN_BYTES) { diff --git a/common/controller/recordLive.ts b/common/controller/recordLive.ts @@ -79,6 +79,7 @@ import { runManagedFunction, type StreamActionResult } from "../jobs/streamComma import { channelExtraArgs, configForVideoUrl } from "../ytdlp/channelArgs"; import { dataDirIdForUrl } from "../ytdlp/runYtdlp"; import { + ensureStoreRoot, landMediaFile, probeMedia, readHandoffFacts, @@ -656,9 +657,7 @@ export async function recordLiveRun( const slugStore = path.dirname(storeDir); const storeRoot = savedVideoRoot(paths, opts.channelConfig); try { - if (!(await stat(storeRoot).then((s) => s.isDirectory(), () => false))) { - throw new Error(`the saved-video store ${storeRoot} is not there (is its drive mounted?) — nothing recorded`); - } + await ensureStoreRoot(paths, storeRoot, "nothing recorded"); await assertSavedVideosStoreWritable(paths, storeDir); const free = await (deps.freeBytes ?? getFreeBytes)(storeRoot); if (free < RECORD_LIVE_MIN_FREE_BYTES) { diff --git a/editor/e2e/live-capture.spec.ts b/editor/e2e/live-capture.spec.ts @@ -43,7 +43,7 @@ test("Import a file: previewed, then landed as the video's source with its audio await form.getByLabel("do not clean").check(); await form.getByLabel("import note").fill("keep this one"); await form.getByRole("button", { name: "Preview import" }).click(); - const preview = form.getByRole("log", { name: `Preview import into ${SLUG}/${ID} output` }); + const preview = form.getByRole("log", { name: `Preview import into ${SLUG}/${ID} output`, exact: true }); await expect(preview).toContainText("remuxed", { timeout: 30_000 }); await expect(preview).toContainText("dry run"); // A dry run lands nothing and moves nothing. @@ -52,7 +52,7 @@ test("Import a file: previewed, then landed as the video's source with its audio await expect(form.getByRole("button", { name: "Import", exact: true })).toBeEnabled(); await form.getByRole("button", { name: "Import", exact: true }).click(); - const run = form.getByRole("log", { name: `Import into ${SLUG}/${ID} output` }); + const run = form.getByRole("log", { name: `Import into ${SLUG}/${ID} output`, exact: true }); await expect(run).toContainText("@@import-media", { timeout: 30_000 }); await expect(run).toContainText("Stored"); @@ -71,7 +71,7 @@ test("Import a file: previewed, then landed as the video's source with its audio test("Keep videos by id: a video the channel does not hold yet is pending, and listed", async ({ page: p }) => { await p.goto(channelStage(SLUG, "cleanup")); const box = p.getByLabel("keep videos by id"); - await box.getByLabel("keep ids").fill("v9notyet01"); + await box.getByLabel("keep ids", { exact: true }).fill("v9notyet01"); await box.getByLabel("keep ids note").fill("keep when it lands"); await box.getByRole("button", { name: "Keep them" }).click(); await expect(box.getByRole("status")).toContainText("1 pending (not here yet)");