soulsync/core/download_plugins
BoulderBadgeDad 53c264ab50 Torrents: fix stall handling on "downloading metadata" + stop orphaning in qbit
noldevin: a magnet stuck "downloading metadata" ran 11h despite a 15-min stall
timeout, got cleared from SoulSync but left active in qbit, then re-grabbed as a
duplicate. Two bugs:

1. Stall never fired on metaDL. StallTracker reset its clock on any `downloaded`
   byte increase, but a metaDL torrent's byte counter still ticks up from DHT/peer
   protocol overhead while making no real progress — so the clock reset forever.
   Fix: the byte counter only counts once metadata is in (size>0). During the
   metadata phase (size==0) the only thing that counts as progress is *obtaining*
   metadata, so a magnet that can't even do that within the timeout is correctly
   flagged stalled. size=None preserves the old byte-only behavior (back-compat).

2. Orphaned in qbit. The monitor's stall exit removed the torrent, but the `error`
   exit and the 6h deadline exit only marked the download failed — leaving the
   torrent active in qbit, untracked here, so SoulSync re-grabbed the same dead
   torrent (qbit logs the duplicate-add). Fix: both terminal exits now run
   _cleanup_torrent (shared with the stall path), which removes+deletes (abandon)
   or pauses per the stall action — nothing is left orphaned.

Tests (10 new): metaDL byte-noise no longer resets the clock (stalls at timeout);
obtaining metadata resets it; real byte-progress still tracked after metadata;
_cleanup_torrent removes+delete_files on abandon / pauses on pause / no-ops on
empty hash or no adapter / swallows a client error. 151 torrent tests green.
2026-06-11 14:37:46 -07:00
..
__init__.py Cin-1: Make DownloadSourcePlugin inheritance explicit on every client 2026-05-04 22:19:52 -07:00
album_bundle.py Fix #796: Soulseek album bundle left completed files in slskd download folder 2026-06-04 21:56:07 -07:00
base.py Address Copilot doc-drift review 2026-05-05 15:46:48 -07:00
registry.py feat(downloads): wire torrent + usenet as live download sources 2026-05-20 17:22:19 -07:00
torrent.py Torrents: fix stall handling on "downloading metadata" + stop orphaning in qbit 2026-06-11 14:37:46 -07:00
torrent_stall.py Torrents: fix stall handling on "downloading metadata" + stop orphaning in qbit 2026-06-11 14:37:46 -07:00
types.py Add torrent and usenet release staging support 2026-05-21 14:22:21 -07:00
usenet.py Fix: torrent/usenet album bundle hard-fails on 'no results' instead of falling back 2026-06-01 09:55:59 -07:00