Auto-retry download by default#86
Draft
Kisty wants to merge 34 commits into
Draft
Conversation
When download fails, it will schedule another download attempt. Defaults autoRetry true. Can be optionally turned off in DownloadConfig.
Author
|
Fixes #85 |
Author
|
While it does retry the download, it seems to create a new file e.g. |
Kisty
marked this pull request as draft
May 15, 2026 00:11
Instead of a new one
Kisty
force-pushed
the
feature/auto-retry-download-by-default
branch
from
May 18, 2026 16:11
ca4bb10 to
5ef9bf3
Compare
- Detect changes in ETag or Content-Length to trigger a fresh download. - Skip redundant downloads if the file is already successful and headers match the database. - Reset `downloadedBytes` and update `totalBytes` when server-side changes are detected. - Add `ServerUpdateTest` to verify update and skip logic.
* Sync database with disk on initialization and during queries to mark missing files as FAILED. * Use a stable hash of the URL for filenames instead of random UUIDs to ensure predictable naming. * Update tests to verify disk consistency and stable ID generation. * Simplify download request preparation logic.
- Throttle disk existence checks in `syncAndMap` to a 5-second interval to reduce I/O. - Optimize `WorkInfo` observation by using an entity map instead of repeated database lookups. - Reduce redundant logging by checking for status transitions before logging events. - Add `PerformanceTest` to verify throttling logic for disk checks. - Remove unnecessary `runBlocking` call in `Ketch.download`.
Author
|
I think this works in theory and in our app. Am just fixing an issue where the download doesn't automatically-retry immediately when it has re-established connection. Will do so by adding a param on DownloadConfig for |
- Add `retryOnNetworkGain` to `DownloadConfig` to control connectivity-based retries (defaults to `true`). - Update `DownloadManager` to apply the `NetworkType.CONNECTED` constraint to work requests when enabled. - Add `ConnectivityRetryTest` to verify `WorkManager` constraint application based on configuration.
Set download work request as expedited to allow retried downloads in background to start notifications (foreground services)
- Introduce a 200ms delay before calling `setForeground()` in `DownloadWorker`. - Mitigate a race condition in Android 14+ where calling `setForeground()` immediately after an expedited worker starts can trigger a `ForegroundServiceStartNotAllowedException`.
…ional backoff criteria
Due to AndroidX Work 2.10.5 upgrade
Start delay increase required for foreground workaround
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
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.
Adds auto-retry downloads by default if the download is not cancelled. Can be optionally disabled in DownloadConfig.
When the download is scheduled for a retry, a new status RETRY_QUEUED is made, so to differentiate between first attempt and any retries.
Also, fixed demo app links & added some basic Worker tests checking statuses as well as checking the auto-retry functionality.