Skip to content

Commit bb1f623

Browse files
committed
fix(test-impact): report a Windows case collision as a collision
A tree with a file `A` and a directory `a` cannot be materialized on a case-insensitive volume. On Windows, creating the file over the existing directory answers ERROR_ACCESS_DENIED, not ERROR_FILE_EXISTS, so the pinned tree reported an I/O failure where tree_d_native_collision_and_exact_spelling expects CBM_PINNED_TREE_COLLISION (observed: error 5 on the create). An access-denied create whose attempted name is present is now the same collision; one whose name is absent stays an I/O failure. Signed-off-by: Martin Vogel <[email protected]>
1 parent 4f709c2 commit bb1f623

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎src/mcp/test_impact_tree_windows.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22
#ifdef _WIN32
33

44
bool tpt_win_error(tpt_context *c, DWORD e, bool creating) {
5-
if (creating && (e == ERROR_ALREADY_EXISTS || e == ERROR_FILE_EXISTS))
5+
/* Creating a file over a directory of the same (case-folded) name answers
6+
* ERROR_ACCESS_DENIED rather than "exists"; with the attempted name
7+
* present it is the same collision. Both create sites leave that name in
8+
* wide_path. */
9+
bool present = creating && e == ERROR_ACCESS_DENIED &&
10+
GetFileAttributesW(c->tree->wide_path) != INVALID_FILE_ATTRIBUTES;
11+
if (creating && (e == ERROR_ALREADY_EXISTS || e == ERROR_FILE_EXISTS || present))
612
return tpt_fail(c, CBM_PINNED_TREE_COLLISION, "exclusive native name already exists");
713
if (e == ERROR_NOT_ENOUGH_MEMORY || e == ERROR_OUTOFMEMORY)
814
return tpt_fail(c, CBM_PINNED_TREE_OOM, "native allocation failed");

0 commit comments

Comments
 (0)