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. |
||
|---|---|---|
| .. | ||
| __init__.py | ||
| album_bundle.py | ||
| base.py | ||
| registry.py | ||
| torrent.py | ||
| torrent_stall.py | ||
| types.py | ||
| usenet.py | ||