VFS: fix move/copy data loss, overwrite flags, and whited-out directory handling #96
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!96
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/96/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?
@raylitebull on GitHub · 2026-11-23 11:10 UTC · original
raylitebull:fix/vfs-move-copy-and-whiteouts→main· +779 −103 · 2 files · 2 commits · merged 2026-11-23 11:25 UTCSummary
Fixes data-loss bugs on VFS move/copy/rename plus whited-out directory listing and type-check bugs in
crates/xcl/src/{vfs.rs, vfs_hooks.rs}(split into 2 clean commits — data-loss fixes first, directory/whiteout fixes second):Commit 1 (Data Loss): Case-only rename, overwrite flags, and failed copy/move whiteout resurrection
vfs_hooks.rs):G:\data\hello.txt->G:\data\HELLO.TXT) copied it into the overlay and then calledv.delete_file("data\\hello.txt"), deleting the newly created overlay file on case-insensitive NTFS and writing a whiteout — permanently destroying the file while returningTRUE.move_file_vfsnow detects same case-insensitive VFS relative paths: self-rename is a no-op, overlaid case-only rename renames in place, and un-overlaid case-only rename copies into the overlay with the new casing and commits without deleting or whiting out.MOVEFILE_REPLACE_EXISTING,bFailIfExists,COPY_FILE_FAIL_IF_EXISTS) (vfs_hooks.rs):move_file_vfsnow enforcesMOVEFILE_REPLACE_EXISTINGacross the full VFS view (un-overlaid original, overlay, and external targets), returningERROR_ALREADY_EXISTSwhen unset andERROR_ACCESS_DENIEDon directories.CopyFileW,CopyFileExW, andCopyFile2(readingdwCopyFlagsafter checkingdwSize >= 8) enforce fail-if-exists against un-overlaid original files (ERROR_FILE_EXISTS/HRESULT_FROM_WIN32(ERROR_FILE_EXISTS)).vfs.rs,vfs_hooks.rs):Vfs::stage_write(creates overlay parent dirs without removing whiteouts) fromVfs::commit_write(removes whiteout only after the underlying copy/move succeeds) so a failing copy/move (e.g. missing source) never resurrects a whited-out original file.hk_replace_file_wvalidates bothreplacedandreplacementexist in the VFS (ERROR_FILE_NOT_FOUND) before mutating files.Commit 2: Whited-out directory listing, type checks, and directory recreation
vfs_hooks.rs):collect_game_entrieschecks!dir_rel.is_empty() && !v.is_dir(&dir_rel)and returnsERROR_PATH_NOT_FOUNDinstead of enumerating.and..from the original directory.vfs.rs):delete_filerejects original directories (ERROR_ACCESS_DENIED) andremove_dirrejects original files (ERROR_DIRECTORY) without writing whiteouts.vfs.rs):remove_whiteoutpushes whiteouts down to immediate original children whenever a whited-out ancestor directory is un-hidden, so recreating a removed directory never resurrects original children.Testing
move_case_only_and_self_rename_preserve_filemove_enforces_replace_existing_and_overwrites_cleanly(including overwriting an existing file and reading it back intact)copy_enforces_fail_if_exists_and_overwrites_cleanly(including overwriting an existing file and reading it back intact)failed_copy_and_move_do_not_resurrect_whiteoutsreplace_file_rejects_missing_or_whited_out_targetsdelete_file_rejects_directories_and_remove_dir_rejects_filesrecreating_removed_directory_does_not_resurrect_original_childrenfind_first_on_whited_out_and_recreated_directoryorigin/main(60599a9, zero conflict with #92):cargo build --workspaceandcargo test --workspace -- --test-threads=4pass (467 passed, 0 failed, 36 ignored, 0 new warnings).@ivall on GitHub · 2026-11-23 11:25 UTC · original
Merged together with #95–#102 and checked on Windows 11 with an RX 9070:
cargo test --workspacegreen with the retail samples (shader pack, console DLLs, texture archive), lib tests also withXCL_SPLIT_WAVE64=1; XDefiant (title screen, a scripted A reaches its "Xbox network unavailable" dialog), Unicorn Overlord and Minecraft run. Thanks!