Storage: do not follow directory symlinks or junctions when computing used bytes #1928
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!1928
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1928/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@ashrafsdrop on GitHub · 2026-11-25 01:07 UTC · original
ashrafsdrop:storage/symlink-recursion-040→main· +21 −6 · 2 files · 1 commits · closed without mergingResolves VIC-BT-040 from #1249:
Summary
When calculating disk space consumption via \used_bytes\ in \crates/victory-hle/src/modules/storage.rs\ and \crates/victory-hle/src/modules/xpackage.rs:
Verification
@AgneyaK on GitHub · 2026-11-25 02:26 UTC · original
Checked this on Windows 11 26300 (NTFS, Rust 1.98.1):
maindoesn't follow junctions or directory symlinks here, so the hang in VIC-BT-040 doesn't happen on Windows.On Windows,
DirEntry::metadata()comes from theFindNextFileWdata and doesn't traverse links (the std docs say so for Windows). A standalone probe withmain'sused_bytesbody, a 1,000-byte file, and a junction (mklink /J) from a subfolder back to the root:So
e.metadata()already behaves likesymlink_metadata, and the junction counts as a non-directory entry of length 0.This PR's test doesn't tell the two apart either. With only its test module put on
main'sstorage.rs,used_bytes_does_not_follow_symlinkspasses, and with the PR it passes too. That's on a machine with developer mode on, sosymlink_dirreally made the link. Where symlinks need privileges,let _ = symlink_dir(...)fails silently and the test checks nothing.What the PR does change:
symlink_metadatacall per entry, whereDirEntry::metadatais free on Windows.If the aim is Unix builds, where
DirEntry::metadatadoes follow links, that's worth saying in the description. A test there would need to fail on the old code, for example byassert!ing that the link was made and counting visits.AI use: Claude Code (Claude Opus 5.5) wrote the probe, ran the checks and wrote this; the results are from the runs described.
@Marvisak on GitHub · 2026-11-25 08:16 UTC · original
Automated triage for the maintainers.
Proposed close.
The bug this fixes is not present on
main.used_bytesincrates/victory-hle/src/modules/storage.rs(andsizeinpackage_bytes,xpackage.rs) usesDirEntry::metadata(), and std documents that this does not traverse symlinks. On Windows it comes straight from theFindNextFileWdata, so a junction or directory symlink already reportsis_dir() == falseand is never recursed into. AgneyaK's comment above confirms this with a junction probe on Windows. The new test passes onmainas well. It also ignores the result ofsymlink_dir(let _ =), so where creating the link fails it checks nothing. The only real change is that a link entry now counts as 0 instead of its own length, plus an extrasymlink_metadatacall per entry.CI:
checkfailing.This PR will be closed in 48 hours unless the author pushes a change (for example, a test that fails on
main) or a maintainer removes the label.Generated by Claude Code
@ashrafsdrop on GitHub · 2026-11-25 11:05 UTC · original
Closing this pull request based on the triage verification. On Windows,
std::fs::DirEntry::metadata()is read directly fromFindNextFileWdata without following reparse points or junctions (is_dir() == false), so directory cycle recursion cannot occur inused_bytes. Thank you for the detailed probe and review.Pull request closed