Xuanwo opened a new pull request, #7201:
URL: https://github.com/apache/opendal/pull/7201
# Which issue does this PR close?
Closes #7062.
# Rationale for this change
`list` currently returns `content_length` as best-effort across services,
which leads users to call `stat` after listing to get stable file sizes.
This PR starts the migration toward mandatory `content_length` for list file
entries by enforcing the guarantee in `CompleteLayer`.
# What changes are included in this PR?
- Add an internal metadata helper:
- `Metadata::has_content_length()` (`pub(crate)`)
- Add internal raw entry metadata accessors used by layers:
- `oio::Entry::metadata()`
- `oio::Entry::metadata_mut()`
- Wrap list results in `CompleteLayer` with `CompleteLister`:
- For file entries without `content_length`, run `stat` (preserving
version when present) and backfill `content_length`
- Return `Unexpected` if file entry still has no `content_length` after
fallback
- Update behavior test `test_list_dir` to validate content length directly
from list entry metadata (instead of calling `stat` in the test itself)
# Are there any user-facing changes?
Yes.
For `Operator::list`/`Operator::lister`, file entries now guarantee
`content_length` via `CompleteLayer` fallback. In cases where a backend cannot
provide content length even after fallback `stat`, listing now returns an
explicit error instead of silently exposing missing size.
# AI Usage Statement
This PR was developed with Codex (GPT-5) for code editing, reasoning, and
test command preparation.
--
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]