Skip to content

Bound repeated download-link refreshes - #15

Merged
Trifocals3537 merged 1 commit into
betafrom
improve/link-refresh-circuit-breaker
Aug 15, 2026
Merged

Trifocals3537 merged 1 commit into
betafrom
improve/link-refresh-circuit-breaker

Conversation

@Trifocals3537

Copy link
Copy Markdown
Owner

Summary

  • add a provider-neutral refresh governor for generated Debrid download links
  • allow one immediate replacement, then apply a per-provider-placement/per-file cooldown when the replacement is also rejected
  • keep probing the cached CDN URL so recovery is detected without waiting for the cooldown
  • coalesce validation-triggered and stream-triggered refreshes into one provider regeneration
  • bound cooldown state to 4,096 entries and clear it immediately on recovery
  • document the behavior without adding UI, configuration, or migration work

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/manager
  • new concurrency/cooldown regressions repeated 10 times under the race detector
  • go test -count=1 -p=3 ./...
  • go vet -p=3 ./...
  • native Linux CGO build and --help smoke test
  • Windows amd64 CGO-disabled cross-build
  • Astro production documentation build
  • git diff --check
  • private deployment-value scan

No deployment was performed.

@Trifocals3537
Trifocals3537 marked this pull request as ready for review August 15, 2026 04:40
Copilot AI lite review requested due to automatic review settings August 15, 2026 04:40
@Trifocals3537
Trifocals3537 merged commit 0e01ef7 into beta Aug 15, 2026
7 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants