Skip to content

fix: report ratio_limit 0 so Sonarr removes completed torrents - #4

Merged
MrJoiny merged 3 commits into
MrJoiny:mainfrom
calmcacil:fix/sonarr-seed-removal
Jul 20, 2026
Merged

fix: report ratio_limit 0 so Sonarr removes completed torrents#4
MrJoiny merged 3 commits into
MrJoiny:mainfrom
calmcacil:fix/sonarr-seed-removal

Conversation

@calmcacil

@calmcacil calmcacil commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Sonarr never removed torrents from TorBoxarr after a successful import. The download would import (copied, since the staging and media volumes are separate filesystems) but then stay in Sonarr's client forever, and no torrents/delete was ever sent.

Root cause is Sonarr's removal gate in QBittorrent.cs HasReachedSeedLimit: for a debrid download that reports ratio: 0 and has no per-torrent seed limit set, the seed-limit check returns false, so CanBeRemoved is false and Sonarr never marks the torrent for removal.

This reports ratio_limit: 0 alongside ratio: 0. In HasReachedSeedLimit, the first branch (RatioLimit >= 0) then evaluates ratio - ratioLimit <= 0.0010 - 0 <= 0.001 → true, so the torrent is treated as past its seed goal and Sonarr sends torrents/delete after import. seeding_time is also reported (0) for completeness. State remains pausedUP, which Sonarr already recognizes.

Test plan

  • Add a release in Sonarr using TorBoxarr as the qBittorrent download client.
  • Confirm the torrent finalizes and Sonarr imports it.
  • Confirm Sonarr then sends POST /api/v2/torrents/delete and the job is removed locally.
  • Verified on our deployment: full cycle now completes (finalize → import → torrents/delete → local removal).

Notes

This branch is based on top of #2 (multipart form-data fix); GitHub shows it stacking cleanly once #2 merges. The diff contains only the ratio_limit/seeding_time change.

Sonarr/Radarr send URL-encoded form data (not multipart) when adding magnet
links. Check Content-Type and fall back to ParseForm when the request is
not multipart, instead of unconditionally calling ParseMultipartForm.
… detection

Covers uppercase Multipart/Form-Data and extra params (e.g. boundary),
per upstream review feedback on PR MrJoiny#2.
…rrent

Sonarr's HasReachedSeedLimit returns false when the torrent has no
seed limit set, so for a debrid download (ratio 0, never seeds) it
never marks the torrent as removable and copies instead of moving,
then leaves it in the client forever. Reporting ratio_limit 0 with
ratio 0 satisfies the first branch of HasReachedSeedLimit
(0 - 0 <= 0.001) so Sonarr treats the completed torrent as past its
seed goal and sends torrents/delete after import.

Keeps state as pausedUP (which Sonarr recognizes) and adds the
seeding_time field for completeness.
@calmcacil
calmcacil force-pushed the fix/sonarr-seed-removal branch from 19d0101 to 07386b6 Compare July 19, 2026 15:01
@MrJoiny
MrJoiny merged commit ece39c5 into MrJoiny:main Jul 20, 2026
4 checks passed
@calmcacil
calmcacil deleted the fix/sonarr-seed-removal branch July 20, 2026 12:35
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.

2 participants