feat: atomic direct-download fallback + ranked-hierarchy continuation - #246
Open
jtstothard wants to merge 2 commits into
Open
feat: atomic direct-download fallback + ranked-hierarchy continuation#246jtstothard wants to merge 2 commits into
jtstothard wants to merge 2 commits into
Conversation
…ation When Anna's Archive direct download fails (zero slow URLs or all links exhausted), atomically fall back to indexer search with a single DB- backed claim to prevent duplicate fallback loops. Fallback searches skip Anna and use the existing protocol routing (qBittorrent for torrents, SABnzbd for usenet). When a ranked ebook candidate permanently fails at either the add-to-client handoff or the monitor/download stage, blocklist that release for the request and automatically continue to the next ranked candidate until one succeeds or candidates are exhausted. Transient connection failures remain retryable and do not trigger fallback. Behavior details: - DB-backed atomic claim prevents race conditions on retry - Request-scoped blocklist excludes previously failed releases - Audiobook requests unchanged - search_attempts not double-counted - Fallback search is marked with isFallback=true Production-tested on A Day of Fallen Night requests showing multiple fallback transitions across Anna, torrent add-failure, and SAB monitor- stage failures. Tests added: - Anna fallback atomicity and claim behavior - Zero URLs and exhausted-links coverage - Ranked continuation after add-to-client failures - Monitor-stage continuation failures - Transient vs permanent failure distinction - Exhaustion behavior
Refactors download failure handling to support atomic fallback from direct download to indexer search and ranked-hierarchy continuation through search candidates. Applies ranked continuation to both ebooks and audiobooks while preserving transient/permanent error semantics. Key changes: - Introduce direct-download-fallback.ts for atomic fallback enqueuing - Replace anna-prowlarr-fallback.ts with generic direct-download-fallback - Add isFallback flag to search_ebook processor to skip direct download sources - Extend ranked-hierarchy continuation to audiobooks (previously ebooks only) - Maintain transient/permanent error distinction in both processors - Ensure no double-counting of searchAttempts Files changed: - src/lib/processors/direct-download.processor.ts: call generic fallback helper - src/lib/processors/download-torrent.processor.ts: rank-continuation for both types - src/lib/processors/monitor-download.processor.ts: lowercase messages, audiobooks continue - src/lib/utils/direct-download-fallback.ts: new atomic fallback implementation - src/lib/utils/anna-prowlarr-fallback.ts: deleted (replaced) - tests/processors/direct-download.processor.test.ts: updated expectations - tests/processors/download-torrent.processor.test.ts: verify audiobook continuation - tests/processors/monitor-download.processor.test.ts: lowercase message expectations - tests/processors/direct-download-fallback.test.ts: new generic fallback tests - tests/processors/ranked-continuation-audiobooks.test.ts: audiobook continuation tests - tests/processors/anna-prowlarr-fallback.test.ts: deleted (replaced) - tests/processors/ranked-continuation-ebooks.test.ts: deleted (covered by generic tests) Verification: - npm exec prisma generate: PASSED - npx tsc --noEmit: PASSED - npm run test: 2596 passed, 4 skipped, 0 failed (full suite green) - npm run build: PASSED
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
What Changed
direct-download-fallbacksearchAttemptsisFallbackto skip direct-download sources during fallback re-searchVerification
npm exec prisma generatenpx tsc --noEmitnpm run test→2596 passed, 4 skipped, 0 failednpm run buildIssue refs