VFS: RemoveDirectoryW refuses a non-empty folder (#997) #1068

Closed
github-bot wants to merge 1 commit from gh-pr/1068/head into gh-pr/1068/base
Owner

@⁠Numbers-iwnl on GitHub · 2026-11-24 11:15 UTC · original
Numbers-iwnl:fix/vfs-remove-non-empty-dir → main · +81 −0 · 2 files · 1 commits · closed without merging

Fixes #997.

What is in it

  • Vfs::remove_dir now reads the merged directory before changing anything: overlay entries plus game entries that are not whiteouted. When it holds an entry the call returns ERROR_DIR_NOT_EMPTY and records nothing, which is what RemoveDirectoryW does on Windows. Before this, a game folder with visible files was whiteouted straight away, so the deletion reported success and overlay\.xcl_whiteouts kept the whole subtree hidden in every later run.
  • New private helper merged_dir_has_entries(rel); both branches of remove_dir use it, so an overlay folder that still holds a file is refused for the same reason.
  • Three existing tests removed a populated folder and assumed it succeeded: vfs::tests::directories, vfs::tests::recreating_removed_directory_does_not_resurrect_original_children, vfs_hooks::tests::find_first_on_whited_out_and_recreated_directory. They now delete the entries first. Their assertions about whiteouts, about recreated folders not resurrecting original children, and about listing a recreated folder are unchanged.
  • New test vfs::tests::a_non_empty_directory_is_not_removed: a game-only folder is refused and nothing is hidden, an overlay folder holding a file is refused, an empty game folder is removed, a folder whose entries are all whiteouted counts as empty, and a missing folder keeps ERROR_FILE_NOT_FOUND.

Tested

  • hardware (GPU + driver, CPU), Rust version, debug / release: Ryzen 7 5700X3D, 32 GB, RX 9070 XT (RDNA4, gfx1201), driver 32.0.32029.2010, Windows 11 26300; Rust 1.98.1; debug.
  • cargo test --workspace -- --test-threads=4: 738 passed, 0 failed, 41 ignored (SKIPPED GPU tests: none — the device reports wave64 and mesh shaders, so no test skipped itself on those grounds).
  • cargo test -p xcl --lib: 695 passed, 0 failed, 21 ignored.
  • cargo test -p xcl --test e2e: 3 passed (needs cargo build --workspace first for xcl_testtitle.exe / testgame_mw.dll).
  • cargo build --workspace: clean apart from the pre-existing deprecated fetch_update warning in hle/xgameruntime/mod.rs:547.

Regression run

Not run. No title was run in this environment, so there is no xcl-smoke block to compare. See Not tested.

Not tested

  • scripts/smoke.ps1 on a real title, from main and from this head. The change only adds a check in front of an existing failure path and touches nothing on the success path or in the overlay write, but a runtime change still needs the smoke comparison before it can merge.
  • The title-driven delete paths (save folders, staged archives) are not covered by any unit test here; the new test uses the same Vfs entry points with synthetic trees.

AI use

  • Hermes Agent (model deepseek-flash) wrote the guard, the helper, the test changes and the commit message, and ran the suites above on the hardware listed. The human author directed the work and reviewed the diff before it was pushed.
**@⁠Numbers-iwnl** on GitHub · 2026-11-24 11:15 UTC · [original](https://github.com/xcl-dev/xcl/pull/1068) `Numbers-iwnl:fix/vfs-remove-non-empty-dir` → `main` · +81 −0 · 2 files · 1 commits · closed without merging Fixes #997. **What is in it** - `Vfs::remove_dir` now reads the merged directory before changing anything: overlay entries plus game entries that are not whiteouted. When it holds an entry the call returns `ERROR_DIR_NOT_EMPTY` and records nothing, which is what `RemoveDirectoryW` does on Windows. Before this, a game folder with visible files was whiteouted straight away, so the deletion reported success and `overlay\.xcl_whiteouts` kept the whole subtree hidden in every later run. - New private helper `merged_dir_has_entries(rel)`; both branches of `remove_dir` use it, so an overlay folder that still holds a file is refused for the same reason. - Three existing tests removed a populated folder and assumed it succeeded: `vfs::tests::directories`, `vfs::tests::recreating_removed_directory_does_not_resurrect_original_children`, `vfs_hooks::tests::find_first_on_whited_out_and_recreated_directory`. They now delete the entries first. Their assertions about whiteouts, about recreated folders not resurrecting original children, and about listing a recreated folder are unchanged. - New test `vfs::tests::a_non_empty_directory_is_not_removed`: a game-only folder is refused and nothing is hidden, an overlay folder holding a file is refused, an empty game folder is removed, a folder whose entries are all whiteouted counts as empty, and a missing folder keeps `ERROR_FILE_NOT_FOUND`. **Tested** - hardware (GPU + driver, CPU), Rust version, debug / release: Ryzen 7 5700X3D, 32 GB, RX 9070 XT (RDNA4, gfx1201), driver 32.0.32029.2010, Windows 11 26300; Rust 1.98.1; debug. - `cargo test --workspace -- --test-threads=4`: 738 passed, 0 failed, 41 ignored (SKIPPED GPU tests: none — the device reports wave64 and mesh shaders, so no test skipped itself on those grounds). - `cargo test -p xcl --lib`: 695 passed, 0 failed, 21 ignored. - `cargo test -p xcl --test e2e`: 3 passed (needs `cargo build --workspace` first for `xcl_testtitle.exe` / `testgame_mw.dll`). - `cargo build --workspace`: clean apart from the pre-existing deprecated `fetch_update` warning in `hle/xgameruntime/mod.rs:547`. **Regression run** Not run. No title was run in this environment, so there is no `xcl-smoke` block to compare. See **Not tested**. **Not tested** - `scripts/smoke.ps1` on a real title, from `main` and from this head. The change only adds a check in front of an existing failure path and touches nothing on the success path or in the overlay write, but a runtime change still needs the smoke comparison before it can merge. - The title-driven delete paths (save folders, staged archives) are not covered by any unit test here; the new test uses the same `Vfs` entry points with synthetic trees. **AI use** - Hermes Agent (model deepseek-flash) wrote the guard, the helper, the test changes and the commit message, and ran the suites above on the hardware listed. The human author directed the work and reviewed the diff before it was pushed.
remove_dir() whiteouted a game folder (or removed an empty overlay copy and
then whiteouted) without looking at the merged directory's entries, so
RemoveDirectoryW succeeded on a folder that still had visible files and the
whole subtree stayed hidden on every later run through .xcl_whiteouts.

Check the merged view first (overlay entries plus game entries that are not
whiteouted) and return ERROR_DIR_NOT_EMPTY without recording anything. The
tests that removed a populated folder now delete its entries first; their
intent - a whiteout on the folder and recreated folders not resurrecting the
original children - is unchanged.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:42:23 +00:00
github-bot closed this pull request 2026-11-26 04:42:23 +00:00
Author
Owner

@⁠Numbers-iwnl on GitHub · 2026-11-24 11:16 UTC · original

Closing under the model policy in CONTRIBUTING.md: the diff and tests were written with DeepSeek, which this repository closes without review. The analysis behind it is in #997, and the branch stays at Numbers-iwnl/xcl:fix/vfs-remove-non-empty-dir.

**@⁠Numbers-iwnl** on GitHub · 2026-11-24 11:16 UTC · [original](https://github.com/xcl-dev/xcl/pull/1068#issuecomment-7129893670) Closing under the model policy in CONTRIBUTING.md: the diff and tests were written with DeepSeek, which this repository closes without review. The analysis behind it is in #997, and the branch stays at Numbers-iwnl/xcl:fix/vfs-remove-non-empty-dir.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.