fix: --stats printed the u128 sentinel as the smallest file size - #372
Open
VXNCXNX wants to merge 1 commit into
Open
fix: --stats printed the u128 sentinel as the smallest file size#372VXNCXNX wants to merge 1 commit into
VXNCXNX wants to merge 1 commit into
Conversation
The sentinel reset was guarded by entries_traversed == 0, but an entry whose metadata cannot be read still counts as traversed while never contributing a size. Reset when the sentinel is still in place instead.
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.
--statson a path it cannot read prints the internal sentinel as the smallest file size.That number is
u128::MAX, the starting value used so the first real file wins the minimum.Cause
The reset was guarded by the wrong condition:
An entry whose metadata cannot be read still increments
entries_traversed, but never contributes a size. So the counter says "we saw something" while the minimum was never set, and the sentinel survives into the output.The fix
Check the sentinel itself rather than inferring it from the counter:
That is true exactly when no size was ever observed, which is the condition the reset actually wants. It also still covers the original empty-traversal case, so nothing is lost.
Verification
unreadable_roots_do_not_leak_the_smallest_file_sentinelinsrc/aggregate.rs,#[cfg(unix)]since it needs a path that fails to stat.Reverting only the condition fails it:
cargo testis 27 + 73 passed,cargo clippy --all-targetsis clean, andtests/stateless-journey.shexits 0 with no snapshot changes needed, since the existing stats snapshots all traverse real files.Tested on Linux. Nothing platform-specific was touched.
Disclosure: written with AI assistance (Claude Code). I built binaries before and after and produced the output above by running them, and ran the mutation check and the journey suite myself.