fix: count real on-disk size, not logical length (0.6.1) - #5
Merged
Merged
Conversation
Scanning summed each file's logical metadata length (`Metadata::len`), which massively over-reports for cloud placeholders: OneDrive online-only files advertise their full cloud size but occupy ~0 bytes locally. On a real drive this produced impossible totals (246 GB used on a 223 GB disk; a single OneDrive tree reporting 70 GB while holding 13 GB). Scanning and the rm/reclaim byte counts now use the allocated on-disk size: GetCompressedFileSizeW on Windows (only for files whose attributes — sparse, compressed, offline, reparse, recall-on-access — can diverge, so the hot path stays a single stat for normal files) and st_blocks*512 on Unix. Duplicate detection keeps using the logical content size, since byte-identical files must group by content regardless of allocation. FileEntry gains `logical_size` alongside `size` (now on-disk). Scan tests assert lower bounds on totals since on-disk rounds up to the block size.
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.
Problem
Scanning summed each file''s logical metadata length (
Metadata::len). For cloud placeholders (OneDrive online-only files) that advertise their full cloud size but occupy ~0 bytes locally, this massively over-reports. On a real drive: 246 GB used on a 223 GB disk, and a single OneDrive tree reporting 70 GB while holding 13 GB.Fix
Scan + rm/reclaim byte counts now use the allocated on-disk size:
GetCompressedFileSizeW, called only for files whose attributes (sparse / compressed / offline / reparse / recall-on-access) can diverge — normal files stay a singlestaton the hot path.st_blocks * 512.Duplicate detection keeps the logical content size (byte-identical files must group by content, not allocation).
FileEntrygainslogical_sizenext tosize(now on-disk).Verified
cargo fmt/clippy -D warningsclean, all tests green.C:\Users\sasch\OneDrive: 12.9 GB (was 70.2 GB logical) — matches real occupancy.