Bound repeated download-link refreshes - #15
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a provider-neutral “refresh governor” that prevents repeated Debrid download-link regeneration loops by allowing one immediate replacement and then enforcing a bounded, per-(provider placement, file) cooldown that clears on recovery.
Changes:
- Added adaptive, per-file refresh cooldown/backoff state (30s doubling up to 5m) with bounded in-memory tracking and eviction.
- Coalesced validation-triggered and explicit Refresh-triggered regenerations via a shared singleflight path.
- Documented the new behavior and troubleshooting guidance in the docs.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pkg/manager/link/service.go | Adds refresh cooldown/backoff state and coalesced refresh path to prevent regeneration loops while still probing cached URLs. |
| pkg/manager/link/service_test.go | Adds unit tests covering cooldown initiation, expiry/backoff growth, recovery clearing, coalescing, cancellation behavior, and bounded state. |
| docs/src/content/docs/help/troubleshooting.md | Documents the new cooldown behavior and related log code for troubleshooting repeated playback errors. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| return emptyDownloadLink, err | ||
| } | ||
| return s.fetchAndValidate(ctx, entry, filename, repairAttempt, linkRefreshes+1) | ||
| return s.refreshRejectedLink(ctx, entry, link, repairAttempt, linkRefreshes) |
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
The cooldown grows from 30 seconds to 5 minutes. It protects every provider from repeated API regeneration loops while leaving unrelated files and providers unaffected. This is especially useful for providers with synchronized API-key limits, such as TorBox's documented 300 requests/minute for most endpoints: https://support.torbox.app/en/articles/13726368-api-rate-limits
Related upstream report: sirrobot01#381
Validation
go test -race -count=1 ./pkg/manager/link ./pkg/managergo test -count=1 -p=3 ./...go vet -p=3 ./...--helpsmoke testgit diff --checkNo deployment was performed.