Skip to content

Commit c679dff

Browse files
fix(studio-server): a same-size clip copied over with its time kept gets its own media copy (#9098)
1 parent 05b34df commit c679dff

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function boxPart(box: PreviewProxyBox | undefined): string {
1616
return box ? formatPreviewProxyBox(box) : "";
1717
}
1818

19-
/** Where a source sits and when it last changed: a hit needs no reading of the file. */
19+
/** Where a source sits and when it last changed, by change time too, which no copy keeps: a hit reads no bytes. */
2020
export async function fastCopyKey(
2121
sourcePath: string,
2222
version: string,
@@ -27,6 +27,7 @@ export async function fastCopyKey(
2727
return digest(
2828
sourcePath,
2929
String(stat.mtimeMs),
30+
String(stat.ctimeMs),
3031
String(stat.size),
3132
version,
3233
variant,

‎packages/studio-server/src/helpers/proxyTranscoder.test.ts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1956,6 +1956,24 @@ describe("resolveProxy", () => {
19561956
expect(calls).toHaveLength(2);
19571957
});
19581958

1959+
it("makes a new copy for a file of the same size copied over with its modified time kept", async () => {
1960+
const { spawn, calls } = createSpawnSpy();
1961+
const env = await loadModule(spawn, FFMPEG_PATH);
1962+
const projectDir = tmpProject();
1963+
const sourcePath = join(projectDir, "clip.mov");
1964+
const pinned = new Date("2026-01-01T00:00:00Z");
1965+
writeFileSync(sourcePath, "first clip");
1966+
utimesSync(sourcePath, pinned, pinned);
1967+
const first = await made(env, calls, projectDir, sourcePath);
1968+
1969+
writeFileSync(sourcePath, "other clip");
1970+
utimesSync(sourcePath, pinned, pinned);
1971+
const second = await made(env, calls, projectDir, sourcePath);
1972+
1973+
expect(second).not.toBe(first);
1974+
expect(calls).toHaveLength(2);
1975+
});
1976+
19591977
it("makes a new copy when a link is retargeted to other bytes", async () => {
19601978
const { spawn, calls } = createSpawnSpy();
19611979
const env = await loadModule(spawn, FFMPEG_PATH);

0 commit comments

Comments
 (0)