Repository navigation
VFS: fix move/copy data loss, overwrite flags, and whited-out directory handling - #96
Merged
Merged
Conversation
…reation whiteouts
Collaborator
|
Merged together with #95–#102 and checked on Windows 11 with an RX 9070: |
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.
Summary
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 VFS hooks: the guard keeps the thread's last error #92):cargo build --workspaceandcargo test --workspace -- --test-threads=4pass (467 passed, 0 failed, 36 ignored, 0 new warnings).