Account for (uplift) hardlinks when calculating clean file size - #17485
ranger-ross wants to merge 2 commits into
Conversation
|
r? @weihanglo rustbot has assigned @weihanglo. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
fwiw, I tried So it seems to be even closer to |
|
Errr, geez didn't realized the windows I guess the PR is still reviewable as the approach should work, I'll just need to use @rustbot author |
|
imo this PR addresses one specific concern and I think that is fully reasonable. We shouldn't block some improvement on trying to make it perfect, especially since each time of improvement likely needs its own decision of whether it is worth it / correct. |
cd990f6 to
6426b25
Compare
6426b25 to
2f806ad
Compare
2f806ad to
5651d3c
Compare
|
I think the |
What does this PR try to resolve?
Reported in #15823.
Currently the size we show in
cargo cleandoes not account for hardlinks.This can lead to large over estimations when there are large files hardlinked during uplifting (like binaries)
I personally have seen Cargo report 2Tb saved when my disk was 1Tb 😆
I briefly considered if we should show both the apparent size and the size on disk, but decided to just stick to showing the size on disk to avoid confusion and feel its want the majority of users will want/expect.
Note: This does not mean the size estimation is now perfectly accurate.
Still missing
targetMetadata::len()does not account for account for filesystem specific allocations. (I thinkMetadataExt::blocks()could handle this better on unix. I didn't do this since testing it would be a bit annoying due to it being filesystem specific, though could be added later)How to test and review this PR?
You can test this pretty easily testable using
du -sh targetand comparing that withcargo clean --dry-run.Testing on ripgrep
(note: we under report now due to reasons above, but its much closer to the true size than before)
AI usage disclosure
I used AI during the investigation of this, but all of the code is handwritten.
I also used it to help simplify the test case and make it more idiomatic/match the style of other tests