Improve large-library reliability with optional stateful engine and adaptive backoff#1321
Open
MadsenDev wants to merge 2 commits intoicloud-photos-downloader:masterfrom
Open
Improve large-library reliability with optional stateful engine and adaptive backoff#1321MadsenDev wants to merge 2 commits intoicloud-photos-downloader:masterfrom
MadsenDev wants to merge 2 commits intoicloud-photos-downloader:masterfrom
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
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.
Summary
This PR improves reliability and scalability for large iCloud photo libraries while preserving existing CLI behavior by default.
It introduces an optional stateful engine mode that unifies retry/backoff handling, adds adaptive throttling, bounded download concurrency, and task-level resumability via SQLite.
Default (stateless) behavior remains unchanged.
This update has not yet been tested with an actual iCloud account.
Motivation
Users with large libraries (50k–200k assets) frequently encounter systemic failures due to:
These issues often require multiple manual restarts to complete large downloads.
This PR addresses those pain points while keeping the existing user experience intact.
Key Changes
1. Unified Retry & Backoff
Retry-Afterfor 429 and 503Applied consistently across metadata queries and downloads.
2. Optional Stateful Engine Mode
Stateless filesystem-based resume remains available if state DB is not used.
3. Bounded Concurrency with Adaptive Throttling
4. Download Improvements
5. Reduced Unnecessary Metadata Requests
--no-remote-count6. Observability & Exit Semantics
Backward Compatibility
--threads-numremains untouched.Trade-offs & Scope
This PR increases internal complexity due to the addition of task persistence and concurrency controls.
However, the goal was to maintain:
Distributed scaling and async rewrites are explicitly out of scope.
Testing
Request for Feedback
This is a larger change set. I’m happy to split this into smaller PRs if preferred, or adjust implementation details based on maintainer guidance.