AryanBagade opened a new pull request, #6832:
URL: https://github.com/apache/opendal/pull/6832
This commit fixes list truncation on large HuggingFace repositories by
implementing proper pagination support following the Hub tree API.
# Which issue does this PR close?
Fixes #6830 (part 2)
<!--
We generally require a GitHub issue to be filed for all bug fixes and
enhancements. You can link an issue to this PR using the GitHub syntax. For
example `Closes #123` indicates that this PR will close issue #123.
-->
# Rationale for this change
Currently, when listing files in large HuggingFace repositories, only the
first page of results is returned, causing truncation. The HuggingFace Hub API
uses Link headers with `rel="next"` for pagination (RFC 8288), but the existing
implementation sets `ctx.done = true` immediately after the first response,
preventing subsequent pages from being fetched.
<!--
Why are you proposing this change? If this is already explained clearly in
the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your
changes and offer better suggestions for fixes.
-->
# What changes are included in this PR?
**Core changes:**
- Added `parse_link_header()` function in `lister.rs` to parse RFC 8288
Link headers
- Modified `HuggingfaceLister::next_page()` to check for next page URL and
store it in `ctx.token`
- Updated `hf_list()` in `core.rs` to accept optional cursor parameter
- Added `hf_list_with_url()` method to fetch subsequent pages using full
URL from Link header
**Tests added:**
- 5 unit tests for Link header parsing covering various formats and edge
cases
- 1 integration test for cursor parameter handling
The implementation follows the same pattern used by the OneDrive service for
consistency.
<!--
There is no need to duplicate the description in the issue here but it is
sometimes worth providing a summary of the individual changes in this PR.
-->
# Are there any user-facing changes?
**Yes - Behavior improvement:** Users listing large HuggingFace
repositories will now receive **all files** instead of only the first page.
This is a bug fix with no breaking changes to the API.
**No action required from users** - the pagination happens automatically and
transparently.
<!--
If there are user-facing changes then we may require documentation to be
updated before approving the PR.
-->
<!---
If there are any breaking changes to public APIs, please add the
`breaking-changes` label.
-->
--
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]