Skip to content

Commit 1d01b9f

Browse files
committed
fix(studio): exclude generated caches from project metadata
1 parent 3eb7b1f commit 1d01b9f

4 files changed

Lines changed: 58 additions & 2 deletions

File tree

‎packages/cli/src/server/fileWatcher.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ const WATCHER_EXCLUDED_DIRS = new Set([
1515
".next",
1616
".thumbnails",
1717
".transcode-cache",
18-
".waveform-cache",
1918
".vite",
19+
".waveform-cache",
2020
"build",
2121
"coverage",
2222
"dist",

‎packages/studio-server/src/helpers/projectSignature.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ const SIGNATURE_EXCLUDED_DIRS = new Set([
2020
".git",
2121
".hyperframes",
2222
".next",
23+
".thumbnails",
24+
".transcode-cache",
2325
".vite",
26+
".waveform-cache",
2427
"build",
2528
"coverage",
2629
"dist",

‎packages/studio-server/src/helpers/safePath.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ import { readdirSync } from "node:fs";
66
// Re-exported here for back-compat with existing `../helpers/safePath.js` imports.
77
export { isSafePath, resolveWithinProject } from "@hyperframes/core";
88

9-
const IGNORE_DIRS = new Set([".thumbnails", "node_modules", ".git"]);
9+
const IGNORE_DIRS = new Set([
10+
".thumbnails",
11+
".transcode-cache",
12+
".waveform-cache",
13+
"node_modules",
14+
".git",
15+
]);
1016

1117
function shouldIgnoreDir(rel: string): boolean {
1218
return rel === ".hyperframes/backup";

‎packages/studio-server/src/routes/projects.test.ts‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,37 @@ describe("GET /projects/:id/signature", () => {
9191
expect(second.signature).not.toBe(first.signature);
9292
});
9393

94+
it("ignores generated cache writes while detecting source edits", async () => {
95+
const projectDir = createProjectDir();
96+
const app = new Hono();
97+
registerProjectRoutes(app, createAdapter(projectDir));
98+
const getSignature = async () =>
99+
(
100+
(await (await app.request("http://localhost/projects/demo/signature")).json()) as {
101+
signature: string;
102+
}
103+
).signature;
104+
105+
const initial = await getSignature();
106+
const generatedFiles = [
107+
[".transcode-cache", "proxy.mp4"],
108+
[".thumbnails", "frame.jpg"],
109+
[".waveform-cache", "peaks.json"],
110+
] as const;
111+
const generatedSignatures: string[] = [];
112+
for (const [dir, file] of generatedFiles) {
113+
mkdirSync(join(projectDir, dir));
114+
writeFileSync(join(projectDir, dir, file), `generated ${dir}`);
115+
generatedSignatures.push(await getSignature());
116+
}
117+
118+
expect(generatedSignatures).toEqual([initial, initial, initial]);
119+
120+
mkdirSync(join(projectDir, "src"));
121+
writeFileSync(join(projectDir, "src", "scene.ts"), "export const scene = true;");
122+
expect(await getSignature()).not.toBe(initial);
123+
});
124+
94125
it("404s for an unknown project", async () => {
95126
const app = new Hono();
96127
registerProjectRoutes(app, {
@@ -132,4 +163,20 @@ describe("registerProjectRoutes — composition discovery (#1384)", () => {
132163
// Only Studio's own backup snapshots are hidden from the tree (#1366).
133164
expect(payload.files).not.toContain(".hyperframes/backup/snapshot.html");
134165
});
166+
167+
it("omits generated cache files from the project file tree", async () => {
168+
const projectDir = createProjectDir();
169+
mkdirSync(join(projectDir, ".transcode-cache"));
170+
writeFileSync(join(projectDir, ".transcode-cache", "proxy.mp4"), "proxy");
171+
mkdirSync(join(projectDir, ".waveform-cache"));
172+
writeFileSync(join(projectDir, ".waveform-cache", "peaks.json"), "[]");
173+
const app = new Hono();
174+
registerProjectRoutes(app, createAdapter(projectDir));
175+
176+
const response = await app.request("http://localhost/projects/demo");
177+
const payload = (await response.json()) as { files?: string[] };
178+
179+
expect(payload.files).not.toContain(".transcode-cache/proxy.mp4");
180+
expect(payload.files).not.toContain(".waveform-cache/peaks.json");
181+
});
135182
});

0 commit comments

Comments
 (0)