import { safeRevalidate } from "../../lib/safeRevalidate"; import { getPaths } from "yt-dlp-transcript-common/lib/paths"; import type { StreamActionResult } from "yt-dlp-transcript-common/jobs/streamCommand"; import { enqueueRepoint } from "yt-dlp-transcript-common/controller/storageLocations"; import { channelMediaBusyReason } from "../../channels/lib/mediaBusy"; // ONE ENQUEUE OF THE RE-POINT JOB, for the two callers that have one: the // Re-point button on /storage and the auto path a Refresh can take. // // Deliberately NOT in `actions.ts`: that file carries "use server", which means // every non-type export in it is a server action — a shared helper cannot live // there, and exporting this one from a "use server" file would put an unguarded // enqueue on the wire under its own endpoint. Same reason // `channels/lib/relocationJob.ts` exists. // // WHAT THIS FILE ADDS over the controller's `enqueueRepoint` is exactly two // things the controller may not have: the editor's busy check (S1's // `channelMediaBusyReason`, which reads the job registry AND the auto-queue // lanes' in-flight units — a digest unit writing a sidecar makes no job record // and is the failure that cost the omnimirror move 131 GB), and the page // revalidations. The job record's shape stays in the controller so the boot // pass and this cannot drift. export async function enqueueRepointJob(opts: { locationId: string; newRoot: string; }): Promise { const paths = getPaths(); return enqueueRepoint({ paths, locationId: opts.locationId, newRoot: opts.newRoot, bins: paths, isBusy: channelMediaBusyReason, afterDone: () => { // Every channel on the location now reads from a different path, so the // pages that draw a media location are stale. No snapshot regen — the // kind is in NO_REGEN_KINDS, and a re-point changes no count. safeRevalidate(["/storage", "/channels", "/"]); }, }); }