Repository navigation
blob/fileblob: list keys in key order when a name sorts before a directory - #3854
Merged
vangent merged 1 commit intoNov 22, 2026
Merged
Conversation
…ctory filepath.WalkDir visits directory "a" before file "a-b", but as keys "a-b" sorts before "a/...". Without a delimiter, the one-slot swap couldn't fix that and the early page stop then skipped or repeated keys. Walk each directory's entries in key order instead, so objects are always visited in key order and the swap and the stop guard are no longer needed. Fixes google#3853
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3854 +/- ##
==========================================
+ Coverage 81.52% 81.59% +0.06%
==========================================
Files 100 100
Lines 12241 12261 +20
==========================================
+ Hits 9980 10004 +24
+ Misses 2260 2256 -4
Partials 1 1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Fixes #3853.
filepath.WalkDirwalks each directory's entries in file name order, so the directoryagets visited before the filea-b, even thougha-bsorts beforea/...as a key. Without a delimiter, the one-slot swap inListPagedcan't fix this when a key is more than one position out of place. The early page stop then puts the token pasta-b, and paged listing ends up dropping or repeating keys.This replaces
WalkDirwith a small walk that sorts each directory's entries by the key they map to (the name, plus "/" for directories). Objects now always come out in key order, so the swap and the extra condition on the early stop are no longer needed.I added
TestListNoDelimiterKeyOrder, which compares unpagedListand every page size against the sorted keys. It fails on master and passes with this change, and the existing tests still pass, including the delimiter case from #3791. I put the test in fileblob instead of drivertest because a new drivertest case would need new recordings for the cloud drivers.