Skip to content

Rename Windows staging files through NtSetInformationFile - #3

Open
solakpetri wants to merge 2 commits into
replicraft:mainfrom
solakpetri:fix/windows-rename-root-directory
Open

solakpetri wants to merge 2 commits into
replicraft:mainfrom
solakpetri:fix/windows-rename-root-directory

Conversation

@solakpetri

Copy link
Copy Markdown

What changed

windows_fs::rename_no_replace now calls NtSetInformationFile(FileRenameInformation) instead of SetFileInformationByHandle(FileRenameInfo). The buffer layout, retained parent handle, bounded name and disabled replacement are unchanged. docs/foundation/IO.md and docs/development/DEPENDENCIES.md now name the native rename class.

Why

SetFileInformationByHandle(FileRenameInfo) refuses a non-null RootDirectory with ERROR_INVALID_PARAMETER. Every rename relative to the retained parent therefore failed on Windows:

  • tablecraft create x.accdb --blank reported publication visibility is uncertain: I/O failed (InvalidInput) and left a .tablecraft-stage-* file in the target folder.
  • Journal sidecar setup and retirement (journal/filesystem_windows/setup.rs, pair.rs) hit the same call, so journaled edits could not complete either.
  • Five Windows tests in tablecraft-io failed with the same error (the publication rename test and four windows_pair_* journal tests).

The native rename class accepts the parent handle with a relative name. It still refuses an existing target with STATUS_OBJECT_NAME_COLLISION, which maps to AlreadyExists, so callers' collision handling is unchanged.

I confirmed the cause with a standalone program on the same machine:

Call RootDirectory Result
SetFileInformationByHandle(FileRenameInfo) parent handle ERROR_INVALID_PARAMETER (87)
SetFileInformationByHandle(FileRenameInfo) NULL, full path renamed
NtSetInformationFile(FileRenameInformation) parent handle renamed
NtSetInformationFile(FileRenameInformation) parent handle, target exists STATUS_OBJECT_NAME_COLLISION

How it was verified

Windows 11 Home 10.0.26300 x64, local NTFS, Rust 1.99.0 (x86_64-pc-windows-msvc):

  • cargo test --release -p tablecraft-io --all-features --lib --bins --tests: 110 lib tests pass, including the 5 that failed before the change.
  • cargo clippy --release -p tablecraft-io --all-targets --all-features -- -D warnings: clean.
  • scripts/check_rust_layout.py and scripts/check_documentation_links.py: pass.
  • CLI, end to end:
    • create --blank succeeds on two NTFS volumes.
    • A second create to the same path is refused with AlreadyExists and leaves no staging file.
    • create --table Items --column Id followed by query journal-insert ... VALUES (42) commits, retires the journal by rename, and reads back the row.

Not run

  • The full workspace test suite.
  • Linux, macOS and Windows ARM64.
  • The desktop host's creation and save flows.

This does not claim Windows runtime qualification beyond these checks.

scripts/check_rust_format.py still reports crates/engines/tablecraft-ace/src/queries/creation/tests.rs here. That mismatch is already on main and is fixed separately in #2; CI on this branch will stop at the format step until that lands.

SetFileInformationByHandle(FileRenameInfo) refuses a non-null
RootDirectory with ERROR_INVALID_PARAMETER, so every parent-relative
publication and journal sidecar rename failed on Windows: database
creation, write copies and journaled edits reported an uncertain outcome
and left the staging file behind. The native FileRenameInformation class
accepts the retained parent handle and still refuses replacement with
STATUS_OBJECT_NAME_COLLISION.
@solakpetri solakpetri changed the title fix(io): rename Windows staging files through NtSetInformationFile Rename Windows staging files through NtSetInformationFile Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant