Repository navigation
fix: cache asset hashes across repeated segments - #156
Merged
Merged
Conversation
renezander030
enabled auto-merge (squash)
October 19, 2026 09:04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Every segment after the first re-hashes both the original media and its staged copy. A long cut list therefore reads entire multi-GB files dozens of times during
compile,add-video, andadd-audio.Cache each file's SHA-1 digest within the process, keyed by its absolute path and validated against its device, inode, size, and nanosecond modification/change timestamps. Keep at most 256 recently used digests. Both equality checks and collision filename generation reuse these digests, while occupied collision candidates are still checked against their actual content.
In the regression with 40 cuts per source, full-file hash reads fall from 78 to 2 per source (39x fewer bytes read for hashing). The test compiles both video and audio and checks every segment's source offset, target start, asset reference, and copied bytes. Additional tests cover occupied hash suffixes, relative paths, edited source/destination files, same-size edits with restored mtime, replacement files, and deleted/recreated assets. The three read-count regressions fail against the unchanged implementation and pass with this patch.
Validation:
npm teston Node 20: fresh TypeScript build; 1,262 passed, one platform-specific skip, zero failures.npm run lint: 210 files checked, clean.python3 -m unittest discover -s python/tests -v: 19 passed.The optional
npx --yes @reneza/skillgate auditpassed its instruction-sync, stray-TODO, and secret checks, but its built-in test gate timed out after 30 seconds on rio. The direct full test command and repository pre-commit hook run without that audit limit.The measured improvement is in bytes read for hashing on Linux; no Windows wall-clock benchmark is claimed. No new dependencies or version bump.
Closes #155.