fix: report ratio_limit 0 so Sonarr removes completed torrents - #4
Merged
Conversation
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
force-pushed
the
fix/sonarr-seed-removal
branch
from
July 19, 2026 15:01
19d0101 to
07386b6
Compare
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
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/deletewas ever sent.Root cause is Sonarr's removal gate in
QBittorrent.csHasReachedSeedLimit: for a debrid download that reportsratio: 0and has no per-torrent seed limit set, the seed-limit check returns false, soCanBeRemovedis false and Sonarr never marks the torrent for removal.This reports
ratio_limit: 0alongsideratio: 0. InHasReachedSeedLimit, the first branch (RatioLimit >= 0) then evaluatesratio - ratioLimit <= 0.001→0 - 0 <= 0.001→ true, so the torrent is treated as past its seed goal and Sonarr sendstorrents/deleteafter import.seeding_timeis also reported (0) for completeness. State remainspausedUP, which Sonarr already recognizes.Test plan
POST /api/v2/torrents/deleteand the job is removed locally.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.