Skip to content

fix(download): remove a cancelled torrent that never started - #1421

Merged
calibrain merged 1 commit into
calibrain:mainfrom
splitsec2:fix/remove-unstarted-torrent
Oct 3, 2026
Merged

calibrain merged 1 commit into
calibrain:mainfrom
splitsec2:fix/remove-unstarted-torrent

Conversation

@splitsec2

Copy link
Copy Markdown
Contributor

Cancelling a torrent download leaves the torrent in the client. _safe_remove_download documents the rule: "torrents: never remove or delete client data (avoid breaking seeding)". That makes sense for a torrent that has data. A torrent that is still at 0% has nothing to seed and nothing to resume, and leaving it behind holds a download slot in qBittorrent's queue or sits there as a dead entry.

I hit this on a qBittorrent that is shared with Sonarr, Radarr and Lidarr and has a download limit. Shelfmark cancelled downloads that were queued (#1420) and left them in the client. Three torrents that never fetched metadata held every active slot, and each torrent added after them waited behind them. Removing those by hand freed the slots.

This removes the torrent and its files when a download is cancelled, Shelfmark added the torrent, and the client reports 0% progress. A torrent with any data is left alone as before. So is one that was already in the client when the download started, since Shelfmark didn't add it. If the removal fails it is logged and the cancel carries on.

Tests cover removal at 0% for a queued and a downloading torrent, leaving one that has data, leaving one the user already had, and a failing removal. The full suite passes, and I broke each rule on purpose to check a test catches it.

This changes a rule you wrote down, so I've kept it apart from the queue fix. If you'd rather have it as a setting, or only remove a torrent that is still queued or fetching metadata, I'm happy to rework it.

Cancelling a torrent download leaves it in the client so one that already has data
can keep seeding. A torrent that is still at 0% has nothing to seed and nothing to
resume, and leaving it queued only holds a download slot and piles up dead
entries.

When a download is cancelled and its torrent has downloaded nothing, remove it from
the client (and its files) if Shelfmark added it. A torrent with data is still left
alone, and so is one that was already in the client before the download started.
@calibrain

Copy link
Copy Markdown
Owner

LGTM !

@calibrain
calibrain merged commit d99e9d7 into calibrain:main Oct 3, 2026
17 checks passed
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