Improve rutracker_check updates for RuTracker and NNMClub#3048
Conversation
|
@IvanShift can you rebase? And also tell me how to test? |
Rework the rutracker_check update flow so it can handle current tracker behavior without treating reachable torrents as deleted. For NNMClub, use tracker scrape as the fast path with a real passkey from the current torrent or another session torrent, then fall back to unauthenticated guest torrent downloads when the scrape does not find the current hash. Patch downloaded guest torrents with the real passkey before replacing the existing torrent, which avoids the Cloudflare-protected login flow and prevents false STE_DELETED results. For RuTracker, keep the API hash check but fall back to direct torrent download and absorbed-topic detection when the API reports a missing/deleted topic or the download endpoint returns an HTML error page instead of a .torrent file. Harden shared replacement handling by matching trackers via comment or announce URL, preserving existing start/label/throttle/ratio state, skipping state updates for hashes that no longer exist, and cleaning up obsolete files after a successful replacement when the new torrent file list differs from the old one.
Replace the transaction's poll/verify machinery with a single ownership marker and one bounded wait for rTorrent's deferred load_raw; every other XMLRPC step is synchronous and checked once. Recover from interrupted replacements: adopt stopped marker-carrying staged copies left by crashed runs, restore the old torrent on every pre-commit failure (including unknowable staged status), never treat a live marked torrent as disposable, and finish cleanup/marker-clear even when post-commit activation cannot be confirmed. Keep obsolete-file cleanup from deleting data the new torrent still references on case-insensitive or normalizing filesystems (inode guard). Restore the STE_DELETED contract for legacy handlers, log curl transport failures on the https path, and replace the recursive scrape bencode decoder with a bounded substring probe. Consolidate the PHP test suites onto a shared TestLib harness; the XMLRPC double now records command parameters so hash-probe targets are pinned. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
3bff931 to
7b5d2d0
Compare
How to testAutomated — no rTorrent or network required: 45 tests, 0 failures (CheckerTest 28, RuTracker 6, NNMClub 8, Snoopy 3), verified on PHP 8.1. They cover the replacement transaction and its rollback/recovery paths, NNMClub scrape + guest-download, RuTracker absorbed-topic detection, and the Snoopy HTTP-method forwarding. Also green locally: Integration testing is still needed against a disposable ruTorrent/rTorrent instance, because the plugin talks to live trackers and session torrents and performs real torrent replacement. Do not use irreplaceable data: a successful update may delete files that existed only in the old torrent. Prerequisites:
Detailed manual test matrix (NNMClub / RuTracker / replacement)NNMClub
RuTracker
Replacement / regression
P.S. Reproducing these integration scenarios against live trackers is not trivial: the hard part is finding real topics that actually exercise the interesting cases — a topic re-uploaded on a regular basis (RuTracker and NNMClub), a topic absorbed/merged (only for RuTracker) into another release, and an update that renames/removes some of the previously downloaded files (any trackers). This coverage can come from a single topic that happens to hit several cases at once, or from several topics that each cover one or two, so lining it all up on real trackers takes some time. |
|
I tested the best I could with rutracker. Didn't test NNMClub . But for the future:
Merging because I was able to test with rutracker and it seems to work. |
Rework the rutracker_check update flow so it can handle current tracker behavior without treating reachable torrents as deleted.
For NNMClub, use tracker scrape as the fast path with a real passkey from the current torrent or another session torrent, then fall back to unauthenticated guest torrent downloads when the scrape does not find the current hash. Patch downloaded guest torrents with the real passkey before replacing the existing torrent, which avoids the Cloudflare-protected login flow and prevents false STE_DELETED results.
For RuTracker, keep the API hash check but fall back to direct torrent download and absorbed-topic detection when the API reports a missing/deleted topic or the download endpoint returns an HTML error page instead of a .torrent file.
Harden shared replacement handling by matching trackers via comment or announce URL, preserving existing start/label/throttle/ratio state, skipping state updates for hashes that no longer exist, and cleaning up obsolete files after a successful replacement when the new torrent file list differs from the old one.