Mola-maker opened a new pull request, #9053:
URL: https://github.com/apache/opendal/pull/9053

   # Which issue does this PR close?
   
   Closes #9052.
   
   # Rationale for this change
   
   On Windows, a conditional (`if_not_exists`) staged write whose destination 
parent has become a regular file fails `hard_link` with 
`ERROR_INVALID_PARAMETER`. That error maps to a temporary `Unexpected`, so 
`RetryLayer` keeps retrying `close()` and the staged file is never removed. 
Linux and macOS report a permanent `NotADirectory` and clean up.
   
   # What changes are included in this PR?
   
   - In `publish_staged_file`, on Windows only: when `hard_link` fails and the 
destination's parent is a file, return a permanent `NotADirectory` with the OS 
error as its source. The existing cleanup then removes the staged file.
   - Add the test `test_staged_conditional_write_cleans_up_on_not_a_directory`. 
It asserts `NotADirectory`, that the error is not temporary, and that the 
staging directory is empty. The assertions are not platform-gated, because 
Linux (`rename_noreplace` → ENOTDIR) and macOS (`hard_link` → ENOTDIR) already 
behave this way.
   
   Verification (Windows 11, rustc 1.99.1):
   
   - The new test fails without the fix (`Unexpected (temporary) ... invalid 
input parameter`) and passes with it.
   - `cargo test -p opendal-service-fs --lib`: everything passes except 
`test_directory_errors_are_permanent`, the existing Windows failure that #9032 
fixes.
   - `OPENDAL_TEST=fs` behavior tests with `OPENDAL_FS_ATOMIC_WRITE_DIR` set: 
138 passed.
   - `cargo clippy -p opendal-service-fs --all-targets -- -D warnings`: clean 
for the Windows host and for `--target x86_64-unknown-linux-gnu`.
   - `git merge-tree` against the #9032 branch merges cleanly.
   
   # Are there any user-facing changes?
   
   On Windows, this failure is now reported as a permanent `NotADirectory`, and 
the staged file is removed.
   
   # Breaking changes
   
   # AI Usage Statement
   
   - Harness: Claude Code
   - Model: Anthropic Claude
   - Effort: default
   - Role: Reproduced the failure on Windows from a lead raised in the review 
of #9032. Wrote the fix and the test, and ran the checks above. A separate 
review pass traced the Linux and macOS error mappings and checked the merge 
with #9032.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to