Repository navigation
refactor(storage): carry the cache hit through open instead of unwrapping it - #567
Merged
Merged
Conversation
BryanFRD
enabled auto-merge (squash)
October 10, 2026 15:22
Contributor
There was a problem hiding this comment.
The refactor doesn't change behaviour: hit is Some only when the cache served the reader, and that's the condition from_cache used to check, so the unwrap goes away with nothing else changing. The new warm-cache test is sound. Cache::fill writes the .b3 digest before it renames the object into place, so polling for the object file can't race the integrity check in open.
One formatting nit inline.
Comment on lines
+299
to
+302
| assert!( | ||
| copied.exists(), | ||
| "the copy is filled in behind the first read" | ||
| ); |
Contributor
There was a problem hiding this comment.
Nit: this fits within the default 100-column width, so cargo fmt --check will want it on one line.
Suggested change
| assert!( | |
| copied.exists(), | |
| "the copy is filled in behind the first read" | |
| ); | |
| assert!(copied.exists(), "the copy is filled in behind the first read"); |
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.
Closes #566
Store::openfor a bucket now returns the cache alongside the reader when the reader came from it ((reader, hit)), and the raw-object branch reopens throughhit. That removes thefrom_cacheflag and thecache.as_ref().unwrap()behind it, and the two identicalObject::Remotearms collapse into one. The invariant is now in the types.No behaviour change. I added two tests that run against the in-process bucket stub, so they need no emulator:
Object::Remote), the cache is filled behind the read, and the next read isObject::Rawwith the same bytes;Object::Remote.Both also pass against the code on main, which is the point: they pin the behaviour the refactor must keep. The only existing test of this branch,
a_cached_download_is_the_same_download, needs a bucket emulator and only runs in CI.