Skip to content

Open source CapCut alternative.

TypeScript

fix(site): drop the starter's missing proxies [rebuild]

David Lece9ed0750a3a
diff --git a/site/public/cut-starter/project.json b/site/public/cut-starter/project.json
index e4fa8e8a..fb40fcdf 100644
--- a/site/public/cut-starter/project.json
+++ b/site/public/cut-starter/project.json
@@ -6518,10 +6518,6 @@
"detected": "rec709",
"fullRange": false
},
- "proxy": {
- "fileName": "08e5bbba-4570-42be-857b-d171ad61a09e.mp4.light.mp4",
- "sizeBytes": 5653968
- },
"width": 1920,
"height": 1080,
"origin": "chat",
@@ -7119,10 +7115,6 @@
"detected": "rec709",
"fullRange": false
},
- "proxy": {
- "fileName": "109acb6a-0305-4319-8f6c-ce6f469140ee.mp4.light.mp4",
- "sizeBytes": 8030942
- },
"width": 1920,
"height": 810,
"origin": "chat",
diff --git a/site/src/cut/server/cloud/starter.test.ts b/site/src/cut/server/cloud/starter.test.ts
new file mode 100644
index 00000000..d5639984
--- /dev/null
+++ b/site/src/cut/server/cloud/starter.test.ts
@@ -0,0 +1,32 @@
+import { describe, expect, test } from "bun:test";
+import fs from "node:fs";
+import path from "node:path";
+
+const STARTER = path.join(process.cwd(), "public", "cut-starter");
+
+// Every fileName anywhere in the doc: masters, proxies, and whatever else
+// points at a media file.
+function fileNames(value: unknown, out: string[] = []): string[] {
+ if (Array.isArray(value)) {
+ value.forEach((v) => fileNames(v, out));
+ } else if (value && typeof value === "object") {
+ for (const [key, v] of Object.entries(value)) {
+ if (key === "fileName" && typeof v === "string") {
+ out.push(v);
+ } else {
+ fileNames(v, out);
+ }
+ }
+ }
+ return out;
+}
+
+describe("starter project", () => {
+ // The seed copies the media folder into each new account; a doc that names
+ // a file outside it 404s in every new account.
+ test("every file the doc names ships in its media folder", () => {
+ const doc = JSON.parse(fs.readFileSync(path.join(STARTER, "project.json"), "utf8"));
+ const shipped = new Set(fs.readdirSync(path.join(STARTER, "media")));
+ expect(fileNames(doc).filter((name) => !shipped.has(name))).toEqual([]);
+ });
+});
diff --git a/site/src/cut/server/cloud/starter.ts b/site/src/cut/server/cloud/starter.ts
index 185b0ac0..0d32bebc 100644
--- a/site/src/cut/server/cloud/starter.ts
+++ b/site/src/cut/server/cloud/starter.ts
@@ -64,7 +64,8 @@ export async function seedStarterProject(userId: string): Promise<void> {
doc.createdAt = now;
doc.updatedAt = now;
- const fileNames = [...new Set(doc.assets.map((a) => a.fileName))];
+ // A proxy rides with its master, so the account's copy reads like the doc.
+ const fileNames = [...new Set(doc.assets.flatMap((a) => (a.proxy ? [a.fileName, a.proxy.fileName] : [a.fileName])))];
const media = await Promise.all(
fileNames.map(async (fileName) => {
const info = await ensureStarterObject(fileName);