-
-
Notifications
You must be signed in to change notification settings - Fork 68
fix: detect tracker health support after qBit upgrade #909
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
staleTime was 5 minutes, meaning after upgrading qBittorrent the new capabilities wouldn't be detected until restart or cache expiry. Reduced to 1 minute so normal user interaction (window focus, navigation) triggers a refresh within a reasonable timeframe.
WalkthroughReduced client-side cache freshness for instance capabilities, updated a Go dependency version, and added internal tracker-include capability tracking and propagation within the qBittorrent client implementation. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant qBittorrentAPI as qBittorrent API
participant TrackerMgr as TrackerManager
Note over Client,qBittorrentAPI: capability refresh flow (periodic / triggered)
Client->>qBittorrentAPI: RefreshCapabilities() — fetch capabilities
qBittorrentAPI-->>Client: capabilities (includes tracker include version)
Client->>Client: applyCapabilitiesLocked(capabilities)
alt tracker include version present
Client->>Client: compute trackerIncludeSupported (compare versions)
Client-->>TrackerMgr: SetUseIncludeTrackers(trackerIncludeSupported)
Note right of TrackerMgr: TrackerManager updates behavior based on flag
else not present
Note right of Client: trackerIncludeSupported = false
end
Client-->>Client: log previousVersion -> newVersion
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Repository UI Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Move tracker include capability detection from go-qbittorrent to qui. When RefreshCapabilities() detects a new version, it now updates the TrackerManager's include capability via SetUseIncludeTrackers(). This fixes the issue where supportsTrackerHealth wasn't detected after upgrading qBittorrent until qui was restarted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
go.sumis excluded by!**/*.sum
📒 Files selected for processing (2)
go.modinternal/qbittorrent/client.go
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
Learnt from: Audionut
Repo: autobrr/qui PR: 553
File: internal/services/crossseed/service.go:1045-1082
Timestamp: 2025-11-06T12:11:04.963Z
Learning: The autobrr/qui project uses a custom go-qbittorrent client library (github.com/autobrr/go-qbittorrent) that supports both "paused" and "stopped" parameters when adding torrents via the options map. Both parameters should be set together when controlling torrent start state, as seen in internal/services/crossseed/service.go and throughout the codebase.
Learnt from: s0up4200
Repo: autobrr/qui PR: 746
File: internal/services/reannounce/service.go:480-481
Timestamp: 2025-12-11T08:40:01.329Z
Learning: In autobrr/qui's internal/services/reannounce/service.go, the hasHealthyTracker, getProblematicTrackers, and getHealthyTrackers functions intentionally match qbrr's lenient tracker health logic (skip unregistered trackers and check if any other tracker is healthy) rather than go-qbittorrent's strict isTrackerStatusOK logic (which treats unregistered as an immediate failure). For multi-tracker torrents, if one tracker is working, reannouncing won't help. The duplication of the health check logic across these three functions is acceptable as it's a simple one-liner, and extracting it would add unnecessary complexity.
📚 Learning: 2025-11-06T12:11:04.963Z
Learnt from: Audionut
Repo: autobrr/qui PR: 553
File: internal/services/crossseed/service.go:1045-1082
Timestamp: 2025-11-06T12:11:04.963Z
Learning: The autobrr/qui project uses a custom go-qbittorrent client library (github.com/autobrr/go-qbittorrent) that supports both "paused" and "stopped" parameters when adding torrents via the options map. Both parameters should be set together when controlling torrent start state, as seen in internal/services/crossseed/service.go and throughout the codebase.
Applied to files:
go.mod
📚 Learning: 2025-11-25T22:46:03.762Z
Learnt from: s0up4200
Repo: autobrr/qui PR: 632
File: internal/backups/service.go:1401-1404
Timestamp: 2025-11-25T22:46:03.762Z
Learning: In qui's backup service (internal/backups/service.go), background torrent downloads initiated during manifest import intentionally use a fire-and-forget pattern with the shared service context (s.ctx). Per-run cancellation is not needed, as orphaned downloads completing after run deletion are considered harmless and acceptable. This design prioritizes simplicity over per-run lifecycle management for background downloads.
Applied to files:
go.mod
📚 Learning: 2025-12-11T08:40:01.329Z
Learnt from: s0up4200
Repo: autobrr/qui PR: 746
File: internal/services/reannounce/service.go:480-481
Timestamp: 2025-12-11T08:40:01.329Z
Learning: In autobrr/qui's internal/services/reannounce/service.go, the hasHealthyTracker, getProblematicTrackers, and getHealthyTrackers functions intentionally match qbrr's lenient tracker health logic (skip unregistered trackers and check if any other tracker is healthy) rather than go-qbittorrent's strict isTrackerStatusOK logic (which treats unregistered as an immediate failure). For multi-tracker torrents, if one tracker is working, reannouncing won't help. The duplication of the health check logic across these three functions is acceptable as it's a simple one-liner, and extracting it would add unnecessary complexity.
Applied to files:
go.modinternal/qbittorrent/client.go
📚 Learning: 2025-12-28T18:44:10.496Z
Learnt from: s0up4200
Repo: autobrr/qui PR: 876
File: internal/logstream/hub_test.go:188-192
Timestamp: 2025-12-28T18:44:10.496Z
Learning: In Go 1.25 (Aug 2025), use wg.Go(func()) to spawn a goroutine and automate the Add/Done lifecycle. Replace manual patterns like wg.Add(1); go func(){ defer wg.Done(); ... }() with wg.Go(func(){ ... }). Ensure the codebase builds with Go 1.25+ and apply this in relevant Go files (e.g., internal/logstream/hub_test.go). If targeting older Go versions, maintain the existing pattern.
Applied to files:
internal/qbittorrent/client.go
🔇 Additional comments (7)
go.mod (1)
13-13: LGTM!The dependency version update aligns with the PR objectives to move tracker include capability detection into qui.
internal/qbittorrent/client.go (6)
25-25: LGTM!The constant follows the established pattern and is consistent with other capability version checks in the file.
50-50: LGTM!The field is well-placed and follows the naming convention of other capability flags in the struct.
221-227: LGTM!The mutex handling is correct—capturing the capability flag under lock and then propagating it to TrackerManager after unlock. This properly addresses the PR's goal of detecting capability changes after qBittorrent upgrades.
229-235: LGTM!The logging improvements enhance observability by showing both the previous and new versions, which will help debug capability detection issues after qBittorrent upgrades.
257-257: LGTM!The capability flag assignment follows the same pattern as other capability checks and correctly uses the trackerIncludeMinVersion constant.
448-452: LGTM!The change from dynamic version checking to returning a cached flag is more efficient and ensures the capability is properly refreshed when qBittorrent is upgraded, which addresses the core issue described in the PR.
Fixes tracker health support (
supportsTrackerHealth) not being detected after upgrading qBittorrent until qui restarts.Changes
Moved capability detection to qui - TrackerManager no longer checks version internally. Instead, qui determines the capability and tells TrackerManager via
SetUseIncludeTrackers().RefreshCapabilities updates TrackerManager - When a version change is detected, the TrackerManager's include capability is updated immediately.
Reduced staleTime - Capabilities cache reduced from 5 minutes to 1 minute so upgrades are detected faster through normal user interaction.
Requires: autobrr/go-qbittorrent#102
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.