Xuanwo opened a new pull request, #8731:
URL: https://github.com/apache/opendal/pull/8731

   # Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and 
enhancements. You can link an issue to this PR using the GitHub syntax. For 
example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   None; two small verified bugs found during maintenance of 
`dav-server-opendalfs`.
   
   # Rationale for this change
   
   Two bugs in `OpendalFs` produced wrong HTTP behavior:
   
   1. **`MKCOL /` panicked.** `create_dir` ran 
`Path::new("/").parent().unwrap()` before the existence check, so a request for 
the root crashed the handler instead of returning `405 Method Not Allowed` (RFC 
4918 §9.3.1).
   2. **`MOVE` on a non-empty collection returned `501 Not Implemented`** even 
when the backend advertises `Capability::rename` and can move the directory 
atomically (e.g. `fs`).
   
   # What changes are included in this PR?
   
   - `create_dir` skips the parent-existence check when the normalized path has 
no parent (root). A missing parent still returns `FsError::NotFound` → HTTP 
`409 Conflict`; an existing target still returns `FsError::Exists` → HTTP `405`.
   - `rename` for collections attempts the backend's native `Operator::rename` 
first when `capability().rename` is advertised (paths are trimmed of the 
trailing slash, which `Operator::rename` requires). `Unsupported`/`NotFound` 
results fall back to the existing empty-collection move so semantics on 
rename-capable backends that cannot move the collection are unchanged. No 
generic copy+delete move is introduced.
   - New real-HTTP loopback tests in `tests/webdav_loopback.rs` cover `MKCOL /` 
→ 405 with the server staying usable, `MKCOL /missing/child` → 409, and `MOVE` 
of a non-empty collection on `fs` → 201 with contents intact, plus `Overwrite: 
F` → 412 and `Overwrite: T` → 204.
   
   # Are there any user-facing changes?
   
   `dav-server-opendalfs` no longer panics on `MKCOL /` and supports `MOVE` of 
non-empty collections on backends with native rename. No API changes.
   
   # Breaking changes
   
   <!--
   Leave this section empty for compatible changes. For breaking changes, add 
the
   breaking-changes label and use the following format outside this comment:
   
   Affected packages: core, bindings/java
   
   Migration:
   - Replace `old_api()` with `new_api()`.
   
   Use package names from dev/src/release/package.rs. Include bindings affected 
by
   behavior changes even when their source files are unchanged. Explain how 
users
   can migrate, or explain the removal and available alternatives.
   -->
   
   # AI Usage Statement
   
   - Harness: pi coding agent (via T3 Code delegate)
   - Model: devin/swe-2
   - Effort: max
   - Role: Root-caused both bugs against the crate and `dav-server` 0.12 
internals, implemented the `fs.rs` fix, wrote the new loopback tests, and ran 
`cargo test`, `cargo clippy`, and `cargo fmt --check` locally. The fallback on 
`NotFound`/`Unsupported` assumes a rename-capable backend that cannot move 
collections reports one of those kinds; the empty-collection path keeps prior 
semantics otherwise.
   
   The accountable human author remains responsible for every submitted claim 
and change.
   


-- 
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