Open source CapCut alternative.
TypeScript
fix(site): a library import lands on the media origin
David Le32cef4987c34
diff --git a/site/src/app/api/cut-cloud/[[...slug]]/route.ts b/site/src/app/api/cut-cloud/[[...slug]]/route.tsindex 5467e627..21cd66fd 100644--- a/site/src/app/api/cut-cloud/[[...slug]]/route.ts+++ b/site/src/app/api/cut-cloud/[[...slug]]/route.ts@@ -8,6 +8,13 @@ import { cutCloudCatchAll } from "@/cut/server/cloud/routes";// (src/cut/server/cloud/routes.ts). The client's cloud driver rewrites the// engine's /api/cut/* paths to this prefix.+// Some of these routes move media rather than rows — a library file copied+// into a project, an export handed on — and a big phone video takes longer+// than the platform's default ceiling, which ends the request mid-copy. The+// copy worker already runs at this ceiling; the routes that hand it work run+// there too.+export const maxDuration = 300;+// The Cut API surface takes machine callers: a `dk_live_` bearer key acts as// its user across the same routes the page uses, and the Cut runner calls// back here with its grant while executing a queued turn.diff --git a/site/src/cut/lib/importQueue.ts b/site/src/cut/lib/importQueue.tsindex f56de2cb..3be7632f 100644--- a/site/src/cut/lib/importQueue.ts+++ b/site/src/cut/lib/importQueue.ts@@ -195,6 +195,13 @@ async function run(job: Job) {upload: undefined,...(asset.type === "image" ? { thumbs: [url] } : {}),});+ // The stored file's route URL redirects to a freshly signed link on every+ // read. Mint it now so the asset settles on the media origin — which the+ // chunk cache keeps and a playing clip reads straight from — instead of+ // being repointed a second time at the next scheduled mint.+ void import("./mediaLinks")+ .then((m) => m.refreshSignedUrls(true))+ .catch(() => {});// Decoders repoint on the URL change; let the frame they are painting// finish before the bytes behind them go away.setTimeout(() => revokeTabUrl(localUrl), 10_000);diff --git a/site/src/cut/lib/mediaLinks.ts b/site/src/cut/lib/mediaLinks.tsindex 1c240c24..fb047c86 100644--- a/site/src/cut/lib/mediaLinks.ts+++ b/site/src/cut/lib/mediaLinks.ts@@ -74,8 +74,14 @@ export function markSignedBatch(projectId: string, expiresAt: number | null) {}/** Re-mint the loaded project's signed URLs and swap them into the store.- * Single-flight; skips while the batch is comfortably fresh unless forced. */-function refreshSignedUrls(force = false): Promise<void> {+ * Single-flight; skips while the batch is comfortably fresh unless forced.+ *+ * Exported for the import queue: a copy that has just landed is holding the+ * `/media` route URL, which re-signs and redirects on every range request and+ * is on no origin the chunk cache keeps. Minting it now puts the asset on the+ * media origin in one move rather than leaving a playing clip to be repointed+ * a second time whenever the next scheduled mint comes round. */+export function refreshSignedUrls(force = false): Promise<void> {if (refreshing) return refreshing;refreshing = (async () => {const b = batch;