Repository navigation
fix: preserve cached captures when snapshot names collide - #257
Merged
Merged
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
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.
What Problem This Solves
Taking two file-cache snapshots with the same name within one second can silently replace the first capture. Concurrent callers can all report success even though only the last caller's bytes remain.
User Impact
An existing capture is preserved. A colliding capture returns an already-exists error instead of overwriting it. The cache filesystem must support hard links; unsupported filesystems return a publication error.
Why This Change Was Made
Publish the completed private copy with an atomic operation that cannot replace an existing name, then remove its temporary name. This follows the repository's existing publication pattern. Filenames and API signatures remain unchanged.
Evidence
Validation and review pins
Passed cache tests,
GOWORK=off go test -race -count=1 ./cache -run '^TestSnapshotFile(PreservesExistingCapture|ConcurrentCollision)$', module tidiness with unchanged module files, vet, full uncached Go tests, formatting and diff checks.Independent native P0–P3 review: no findings. Base:
798b6806ab443ee4282c1739f65e17f46e6f0328. Complete candidate:d65f22b8863ecddda90431fb05c84fd37bc820c0. Scope: complete diff, file copying, naming tests, and the existing publication pattern; isolated read-only review.