Repository navigation
fix: stalled torrents wait in the client instead of being cancelled; find them by hash - #66
Merged
Merged
Conversation
…find them by hash A torrent with no progress for 5 minutes (no peers yet, queued in Deluge, or MAM's tracker refusing it for now) was cancelled by the stall check but left downloading in the client, so it finished there with nothing to import it and showed as Cancelled. - A stalled download that's in a hash-keyed torrent client (Deluge, qBittorrent, Transmission, rTorrent) gives up its worker and waits on Activity -> Queued; a watcher sends it back to the workers once the client shows it moving or finished, and fails it if it's no longer there. - The client's hash is kept on the task when the torrent is handed off (and as the retry hash), and finding an existing download tries it first as a magnet: a retry no longer has to download the .torrent, which MAM refuses during its download freeze. - Client display names move to the clients package for reuse. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0184DMrDNkAEmGzPntj3ziqB
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.
Why
After #65, a batch of MAM torrents went to Deluge. The ones within the unsatisfied limit finished downloading, yet every one of them showed as Cancelled in Shelfmark.
The cause is the stall check. It cancels any download with no progress for 5 minutes. A torrent sitting at 0% in the client (no peers yet, Deluge's own queue, or MAM's tracker refusing it while over the limit) was cancelled but left in the client. It finished there with nothing to import it, and the worker's "Cancelled" message overwrote the stall reason.
Retrying one also hit MAM's download freeze. Finding an existing torrent meant downloading the
.torrentagain to get its hash, and MAM refuses that during the freeze. So the retry wasn't recognized as already in Deluge and waited for the freeze.What changes
DownloadTask.torrent_client_hashis set when the torrent is added to (or found in) the client. It also fillsretry_expected_hashwhen the release had none.find_existing_downloadtries the known hash as a magnet before the URL, so no.torrentfetch is needed. It's used by the handler and by the slot check's "already in the client" test.mam_accounttodownload.clients.client_label.Testing
tests/download/test_wait_in_client.py(13 tests) covers:.torrentfetchpytest tests/download tests/prowlarr: 1216 passed. In the full suite the only failures are the 7 entrypoint/hardlink tests that also fail on a cleanmainin this container (they run as root).Known limit
The history row's retry data is only saved when a download finishes or is cancelled. After a restart mid-download, a retry falls back to finding the torrent by URL, which MAM refuses during a freeze.
🤖 Generated with Claude Code
https://claude.ai/code/session_0184DMrDNkAEmGzPntj3ziqB
Generated by Claude Code