Xuanwo opened a new pull request, #8842:
URL: https://github.com/apache/opendal/pull/8842
# Which issue does this PR close?
None.
# Rationale for this change
`MonoiofsDeleter::delete_once` resolves paths through `confined_join`, which
strips trailing `/` characters, and then inspects the target with
`monoio::fs::metadata`. As a result, calling `op.delete("file.txt/")` against a
regular file silently deletes `file.txt` instead of rejecting the directory
path with `ErrorKind::NotADirectory`. Because `monoiofs` also followed symlinks
with `metadata` and did not ignore `NotFound` from `remove_dir` /
`remove_file`, deleting a dangling symlink silently left it behind, deleting a
symlink to a directory failed with `ENOTDIR`, and concurrent deletes could
surface `NotFound`.
Auditing `CompfsDeleter::delete_once` against `FsDeleter` showed matching
semantic gaps: `compfs` dispatched solely on `path.ends_with('/')`, so deleting
a regular file through a directory path returned a temporary
`ErrorKind::Unexpected` instead of `ErrorKind::NotADirectory`, deleting an
empty directory without a trailing slash failed with `EISDIR`
(`ErrorKind::Unexpected`), and symlink handling diverged from `fs`.
# What changes are included in this PR?
- `core/services/monoiofs/src/deleter.rs`:
- Inspect entries with `monoio::fs::symlink_metadata` inside a single
dispatched async task.
- Reject directory-suffixed deletes (`path.ends_with('/')`) targeting a
regular file or a symlink to a file with `ErrorKind::NotADirectory`, leaving
the target untouched.
- Unlink symlinks without removing their targets, treat directory-suffixed
deletes on dangling symlinks as a no-op leaving the link in place, and treat
`NotFound` from `remove_dir` / `remove_file` as `Ok(())` to match `FsDeleter`.
- Add unit tests covering regular files, directory paths, missing entries,
non-empty directories, and symlinks (adding `tempfile` to
`core/services/monoiofs/Cargo.toml` dev-dependencies).
- `core/services/compfs/src/deleter.rs`:
- Align `CompfsDeleter::delete_once` with `FsDeleter` using
`compio::fs::symlink_metadata` and `compio::fs::metadata`, including the
`#[cfg(windows)]` `is_symlink_dir()` branch.
- Add matching unit tests.
# Are there any user-facing changes?
- `monoiofs`: `delete("file.txt/")` and `delete("link.txt/")` now return
`ErrorKind::NotADirectory` and preserve the file/link instead of deleting it.
Deleting symlinks removes the link itself rather than following it, matching
`fs`.
- `compfs`: `delete("file.txt/")` and `delete("link.txt/")` now return
`ErrorKind::NotADirectory` instead of `ErrorKind::Unexpected`; deleting empty
directories without a trailing slash succeeds; symlink deletion matches `fs`.
# Breaking changes
# AI Usage Statement
- Harness: pi
- Model: Gemini 4 Neon
- Effort: high
- Role: Audited `monoiofs` and `compfs` deleters against `fs`, implemented
the fixes and unit tests, and verified them on Linux. The `#[cfg(windows)]`
`is_symlink_dir()` branch in `compfs` was verified against the `compio-fs` API
definition and relies on Windows CI for platform compilation and runtime
coverage.
--
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]