-
Notifications
You must be signed in to change notification settings - Fork 120
[Local Catalog] Background catalog download #16337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
joshheald
wants to merge
10
commits into
trunk
Choose a base branch
from
feat/WOOMOB-1173-background-catalog-download-updated
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[Local Catalog] Background catalog download #16337
joshheald
wants to merge
10
commits into
trunk
from
feat/WOOMOB-1173-background-catalog-download-updated
+656
−37
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…est in the background using `URLSessionConfiguration.background`.
Resolves merge conflicts by integrating background download functionality with trunk's complete catalog sync implementation: - Updated POSCatalogSyncRemote to use BackgroundDownloadService while preserving trunk's full protocol - Added cellular data preference support to background downloads - Updated BackgroundDownloadProtocol and BackgroundDownloadService to accept allowCellular parameter - Modified MockBackgroundDownloader to track cellular preference in tests - Merged test suites to cover both background downloads and cellular preference tests The downloadCatalog method now uses background URLSession with configurable cellular access, maintaining compatibility with trunk's POSCatalogFullSyncService flow. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Implements `application(_:handleEventsForBackgroundURLSession:completionHandler:)` to support background catalog downloads when the app is suspended. - Handles background URLSession events for catalog download sessions - Stores completion handler for iOS to call when background tasks complete - Adds logging for debugging background download lifecycle - Includes TODO for wiring completion handler to BackgroundDownloadService This enables the POS catalog sync to continue downloading large catalog files even when the app is suspended or terminated by the system. Related: WOOMOB-1173 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Resolves "file couldn't be opened" error by ensuring downloaded files persist until parsing completes. **Problem:** iOS immediately cleans up the temp file location returned by URLSession delegate after the callback completes, but async/await parsing happens later, causing "file not found" errors. **Solution:** - Move downloaded file to managed temp location that persists beyond delegate callback - Always clean up file after parsing (simplified from conditional cleanup) - Add better logging for debugging download lifecycle **Changes:** - BackgroundDownloadService: Move file to persistent temp location immediately - POSCatalogSyncRemote: Always clean up downloaded file after parsing This ensures the file exists when parsing starts while still cleaning up properly after use. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Collaborator
Generated by 🚫 Danger |
Collaborator
|
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

Part of: WOOMOB-1173
Description
This PR moves full sync downloads using the full catalog file API to use background URLSessions
This is a follow-up on #16048 to bring it up to date with trunk and finish the work.
Note that in this PR, we handle the parsing and database insert when we open POS again. A future PR will use our available background time at the end of the request to move everything to the database.
Also note that background sessions don't work for the polling requests to see when catalog generation is done, which tends to take longer than downloading the catalog. Discussion: p1762799234106449-slack-C070SJRA8DP
Test Steps
Backgrounded testing is tricky, and you can't really do it with the debugger attached. I've found network breakpoints are useful.
pointOfSaleCatalogAPIfeature flagPOSLocalCatalogEligibilityService.Constants.defaultCatalogSizeLimitto 100000Tools > Network conditions > +then set the host tolargefuntesting.mystagingwebsite.comand use the preset profile. Note that this is only wanted for the file download, so no need to do it on public-api.wordpress.com. For these settings, 3g takes about 30s to download, and 2g takes about 2 minutes.POS > Settingsand tap refresh catalog/wc/v3/products/catalog, wait for thecompletedstatus response with a download URL (this takes a few minutes)Menu > Settings > Help and Support > Application logs > CurrentScreenshots
RELEASE-NOTES.txtif necessary.