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

   # Which issue does this PR close?
   
   N/A.
   
   # Rationale for this change
   
   When `dav-server` handles a SabreDAV append `PATCH` request (`Content-Type: 
application/x-sabredav-partialupdate` with `X-Update-Range: append`), 
`handle_put` opens the file with `OpenOptions { write: true, append: true, .. 
}` and calls `file.seek(SeekFrom::Start(0))` before streaming the request body.
   
   Previously, `OpendalFile` placed append-opened writers into 
`State::Writing`, and `OpendalFile::seek` rejected every non-read state with 
`FsError::GeneralFailure`, which `dav-server` translates into HTTP `416 Range 
Not Satisfiable`. As a result, every legal SabreDAV append `PATCH` request 
failed with 416.
   
   # What changes are included in this PR?
   
   - Track append-opened writers separately in `State::Appending { writer, 
offset, written }` in `integrations/dav-server/src/file.rs`, initializing 
`offset` from existing metadata when `stat` is supported (aborting the writer 
if `stat` fails or targets a directory) and updating `offset` and `written` 
after each write.
   - Allow `DavFile::seek` on `State::Appending` for `SeekFrom::Start(0)` 
before any bytes are written, as well as `SeekFrom::Start(offset)`, 
`SeekFrom::Current(0)`, and `SeekFrom::End(0)`, returning the current append 
offset.
   - Reject non-append writer seeks and out-of-position append seeks with 
`FsError::NotImplemented` so unsupported random-offset partial `PUT` / `PATCH` 
requests fail cleanly without truncating or corrupting existing files.
   - Map write and flush errors through `convert_error` after aborting the 
writer and transitioning to `State::Failed`.
   - Add direct `DavFile` tests in `integrations/dav-server/tests/test.rs` and 
end-to-end loopback tests in `integrations/dav-server/tests/webdav_loopback.rs` 
covering SabreDAV append `PATCH`, cursor accounting, append write/flush abort 
handling, and rejection of unsupported range updates.
   
   # Are there any user-facing changes?
   
   SabreDAV append `PATCH` requests (`Content-Type: 
application/x-sabredav-partialupdate`, `X-Update-Range: append`) now succeed 
against OpenDAL backends that support append writes instead of always returning 
HTTP `416 Range Not Satisfiable`.
   
   # Breaking changes
   
   # AI Usage Statement
   
   - Harness: pi
   - Model: Gemini 4 Neon
   - Effort: high
   - Role: Investigated the `dav-server` append `PATCH` call sequence and 
`OpendalFile` state handling, implemented the fix in 
`integrations/dav-server/src/file.rs`, and added unit and WebDAV loopback 
regression tests.
   


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