Move all enumeration pagination-related state into page data#89
Conversation
Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
…struct, make token optional Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
…of the EnumeratorPageResponse Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
…onObserver Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
There was a problem hiding this comment.
Pull Request Overview
This PR refactors pagination-related state in the enumerator by moving all enumeration pagination details into the page data and updating both tests and production code to handle the new state model. Key changes include updating pagination token handling in tests, modifying the EnumeratorPageResponse model to support optional tokens and additional URLs, and refactoring the Enumerator’s pagination logic and logging.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| Tests/NextcloudFileProviderKitTests/EnumeratorTests.swift | Updates test logic for paginated enumeration and token handling. |
| Tests/Interface/MockEnumerationObserver.swift | Adjusts async handling and visibility of properties in the observer for better state management. |
| Sources/NextcloudFileProviderKit/Enumeration/EnumeratorPageResponse.swift | Refactors page response data model to support optional tokens and additional URL queues. |
| Sources/NextcloudFileProviderKit/Enumeration/Enumerator.swift | Refactors pagination state management and logging in the enumerator. |
Comments suppressed due to low confidence (3)
Tests/NextcloudFileProviderKitTests/EnumeratorTests.swift:621
- The force unwrap of 'token' may lead to a runtime crash if 'token' is nil. Consider adding safety checks or handling the nil case explicitly.
let followUpPage = NSFileProviderPage(initialNextPage!.token!.data(using: .utf8)!)
Sources/NextcloudFileProviderKit/Enumeration/EnumeratorPageResponse.swift:15
- Changing 'token' to an optional requires ensuring that all consumers of EnumeratorPageResponse properly handle the nil case to avoid potential runtime issues.
let token: String? // Required by server to serve the next page of items
Tests/Interface/MockEnumerationObserver.swift:47
- [nitpick] Invoking an async function within the initializer can lead to unexpected behavior. Consider moving asynchronous operations outside the initializer to ensure proper error handling and initialization flow.
try await enumerateItemsPage(page: page)
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #89 +/- ##
==========================================
+ Coverage 83.83% 83.97% +0.14%
==========================================
Files 70 70
Lines 15603 15749 +146
==========================================
+ Hits 13080 13225 +145
- Misses 2523 2524 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Fixes instances where the system passes page data into new enumerator instance rather than reusing existing enumerator