Repository navigation
fix(studio-server): a same-size clip copied over with its time kept gets its own media copy - #9098
Conversation
…ets its own media copy
jrusso1020
left a comment
There was a problem hiding this comment.
Reviewed at 3cd58c8. Approve.
Read whole: proxyCacheKey.ts. Read as hunks plus the surrounding flow: proxyTranscoder.ts (getCanonicalProxyCachePath, transcodeToCache, the still path) and the "finding the copy of a source" tests. Nothing run locally (no install on this box); checks were still pending when I read.
What I checked:
- The fast key now takes the change time, so a same-size file copied over with its modified time kept gets a new fast name. The lookup then misses and
transcodeToCachereads the bytes, so a different file gets its own copy. - A file whose bytes did not change (touch, re-save, chmod, rename) misses the fast name once, finds its copy through the content index and writes a new fast index. The existing "only touched or re-saved" row still covers that path.
- The body's
fails without the fix:line names a real row. Both writes are 10 bytes with the same pinned modified time, so on main the second lookup returns the first copy with one ffmpeg call; the 80 ms flush insidemadekeeps the two change times apart. - Both callers of
fastCopyKey(copies and stills) take the change with no other edit needed; the stills test that builds a key by hand goes through the same function.
Notes, not blockers:
- After this lands every source misses once and is read whole to find its copy by content; for a project of large clips the first open costs one full read per clip. The body says so.
- Stills are cut again after any change-time move (rename, permission change), since they have no content index. Cheap, and correct.
Need: yes, a replaced clip could show the old picture · Size: 2 lines + 1 test · Reuse: existing content index does the recovery · Simpler: no · Structure: fine
Risk: low; worst case is an extra read or re-cut, never a wrong copy.
— Rames
Edit accuracy: accurate 275 (base branch 273), smooth 56 of thoseThe gate passes. Newly passing (2)
Not banked yet, reported and not gated (bank a full-grid run's baseline.json) (2)
Quarantined, measured but not gated (0) |
What
A video replaced by another of exactly the same size, copied over with its modified time kept, now gets a media copy of its own. Before, previews and the project server served the copy made from the file it replaced.
Why
The fast cache lookup names a copy by the source's path, modified time and size.
cp -p, rsync with times kept, or an unzip can keep all three and still change the picture. With real ffmpeg on main: a red clip is copied (red), a blue clip of the same size is copied over it withcp -p, and asking again returns the same red copy. Found in review of #9086.Related work
Refs #9086, which binds a copy to the file state it was made from. That check runs when a copy is made or reused by content, not when the fast lookup finds an old copy.
How
fastCopyKey(proxyCacheKey.ts) also takes the source's change time. No copy tool sets it, and every write or rename of the file moves it..content-index), as a touched file already does. Stills have no content index, so each is cut again once.Test plan
fails without the fix:
packages/studio-server/src/helpers/proxyTranscoder.test.ts("makes a new copy for a file of the same size copied over with its modified time kept").resolveProxyand ffmpeg 6.1, built from this branch and from main, on the red/bluecp -pcase above, read back as colours: main returns the red copy again; this branch makes a new blue copy.Package size: studio-server unpacked is 26 bytes larger, within its budget, also with #9086 counted. Not run: Windows outside CI, and a FAT or exFAT drive, where the change time may not be kept, so a hit there works as before.