Xuanwo opened a new pull request, #8741:
URL: https://github.com/apache/opendal/pull/8741
# Which issue does this PR close?
Closes #.
# Rationale for this change
`MokaLister::new` and `MiniMokaLister::new` accepted the requested list path
as `_path` and ignored it, snapshotting **every** entry in the cache on each
`list` call. The wrapping `HierarchyLister` masked this in non-recursive mode
by re-filtering relative paths, but in recursive mode it trusts the inner
lister directly, so `list("a/", recursive)` also returned entries from
unrelated prefixes such as `ab/` and `b/`. Even when the hierarchy filter saved
the result, every list cloned metadata for the entire cache.
This was found during routine maintenance; no issue was filed first per the
maintenance workflow.
# What changes are included in this PR?
- `core/services/moka`: `MokaBackend::list` now builds the absolute listing
prefix via `build_absolute_path(&self.root, path)` (same as write/delete) and
`MokaLister` filters cache keys by that prefix before collecting the snapshot.
- `core/services/mini_moka`: same fix; the backend already computed the
prefix but the lister ignored it.
- `core/services/mini_moka`: `MiniMokaLister` now maps an empty relative
path to `"/"`, matching `MokaLister` and `MemoryLister`, so a stored root
marker yields a consistent root entry.
- `core/services/mini_moka/Cargo.toml`: add `tokio` dev-dependency (already
used by `opendal-service-moka`) for the new async unit tests.
- New unit tests in both crates covering: recursive `list("a/")` returns
only the `a/` subtree with sibling `ab/` and `b/` present; the same under a
non-`/` configured root (`/sub`); non-recursive `list("a/")`, non-recursive
root `list("/")`, and recursive root list.
Checked for related listing gaps while in the area: neither service
advertises `list_with_start_after`, and `CorrectnessCheckLayer` rejects
`start_after` before it reaches the service, so no other list option needed
fixing.
# Are there any user-facing changes?
Yes — bug fix only. Recursive `list` on `moka`/`mini_moka` no longer returns
entries outside the requested prefix. No API or capability changes.
# Breaking changes
# AI Usage Statement
- Harness: pi-coding-agent (T3 Code)
- Model: Claude Opus 4.6 (Anthropic), default effort
- Role: Located the bug, implemented the fix and tests, ran all local
verification commands listed in the PR checks. Assumption confirmed against the
codebase: cache keys omit the leading `/` and `build_absolute_path` joins root
+ operation path consistently with write/delete paths.
Local verification (run from `core/`):
- `cargo test -p opendal-service-moka -p opendal-service-mini-moka` — 12
unit tests + doctests pass
- `OPENDAL_TEST=moka cargo test --features tests,services-moka --test
behavior list` — 19 passed
- `OPENDAL_TEST=mini_moka cargo test --features tests,services-mini-moka
--test behavior list` — 19 passed
- `cargo clippy -p opendal-service-moka -p opendal-service-mini-moka
--all-targets -- -D warnings` — clean
- `cargo fmt --all -- --check` — clean
--
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]