Xuanwo opened a new pull request, #8946:
URL: https://github.com/apache/opendal/pull/8946
# Which issue does this PR close?
N/A
# Rationale for this change
`dav-server-opendalfs` had four WebDAV correctness bugs across
object-store-like backends and filesystem operations:
1. **Implicit/virtual object-store directories**: On object-store backends
where writing `a/b/c.txt` does not create explicit `a/` or `a/b/` marker
objects (and where `stat("a/")` returns `NotFound`), `OpendalFs::metadata`,
`OpendalDirEntry::metadata`, `OpendalFs::create_dir`, and `OpendalFs::rename`
failed to recognize implicit prefix directories. This caused implicit
directories to disappear from `PROPFIND` and broke `MKCOL`, `COPY`, and
`DELETE` on those prefixes.
2. **Trailing-slash `Destination` on file `MOVE`/`COPY`**: When a WebDAV
client sends `MOVE` or `COPY` for a file with a trailing-slash `Destination`
(for example `/dst/`), `dav-server` removes any existing destination collection
and passes the trailing-slash `to` path to `OpendalFs::rename` or
`OpendalFs::copy`. Passing a trailing-slash path to `Operator::rename` or
`Operator::copy` failed with `IsADirectory` (`403 Forbidden`) after the
destination had already been deleted.
3. **Collection `rename` fallback colliding with an existing file**: In
`OpendalFs::rename` for collections, destination collision checks only tested
`op.exists(to_path)` (the directory key `dst/`), not the file key `dst`. On
backends where `dst` and `dst/` are distinct keys and native collection rename
is unsupported, moving a collection onto an existing file could create `dst/`
alongside `dst` instead of returning `FsError::Exists`.
4. **Trailing `'/'` in `OpendalDirEntry::name`**: `OpendalDirEntry::name`
returned `Entry::name()` directly, which includes a trailing `'/'` for
directory entries in OpenDAL. `dav_server::fs::DavDirEntry::name` expects the
bare entry name without a trailing slash; the extra slash produced malformed
links (such as `sub//`) in `dav-server` autoindex HTML.
# What changes are included in this PR?
- Shared `implicit_dir_exists` and `dir_exists` helpers in
`integrations/dav-server/src/utils.rs` (reused by `file.rs` and `fs.rs`) to
detect both explicit directory markers and implicit prefix directories via
`lister_with(dir_path).limit(1)`.
- Updated `OpendalFs::metadata` (`integrations/dav-server/src/fs.rs`) to
synthesize directory metadata for `"/"` and implicit prefix directories when
`stat` returns `NotFound`, while still returning `FsError::NotFound` for
missing paths and preserving file vs. directory semantics.
- Updated `OpendalDirEntry::metadata` (`integrations/dav-server/src/dir.rs`)
to fall back to the listing entry's directory metadata when `stat` returns
`NotFound` for an implicit directory entry.
- Updated `OpendalDirEntry::name` (`integrations/dav-server/src/dir.rs`) to
trim trailing `'/'` from directory entry names.
- Updated `OpendalFs::create_dir` and `OpendalFs::rename`
(`integrations/dav-server/src/fs.rs`) to use `dir_exists` and check both file
(`dst`) and directory (`dst/`) forms before creating a collection, preventing
file/collection collisions.
- Updated `OpendalFs::rename` (file branch) and `OpendalFs::copy`
(`integrations/dav-server/src/fs.rs`) to reject `"/"` as source or destination
with `FsError::Forbidden` and strip trailing `'/'` from the destination path
before calling `Operator::rename` / `Operator::copy`.
- Added regression tests in `integrations/dav-server/tests/test.rs` covering
all four fixes across both `Memory` (including a wrapper disabling `stat`
directory simulation and native `rename`) and `Fs` backends through
`DavHandler`.
# Are there any user-facing changes?
WebDAV clients using `dav-server-opendalfs` now observe implicit
object-store directories in `PROPFIND`/`COPY`/`DELETE`/`MKCOL`, bare directory
names in `DavDirEntry::name` and autoindex HTML, proper handling of
trailing-slash `Destination` headers on file `MOVE`/`COPY`, and `412`/`409`
conflict protection when renaming a collection onto an existing file.
# Breaking changes
# AI Usage Statement
- Harness: pi
- Model: Gemini 4 Neon
- Effort: high
- Role: Audited `integrations/dav-server` against the reported bugs,
implemented the fixes and integration tests, and verified formatting, clippy,
tests, and rustdoc locally. Note that implicit object-store directory behavior
is verified via an in-process OpenDAL `Layer` wrapper over `services::Memory`
that returns `NotFound` for directory `stat` calls rather than against a live
cloud object store.
--
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]