Skip to content

telegram: notify when a hash check finds a complete torrent incomplete - #3532

Merged
xirvik merged 1 commit into
Novik:masterfrom
Heliedan:telegram-check-failed
Nov 10, 2026
Merged

xirvik merged 1 commit into
Novik:masterfrom
Heliedan:telegram-check-failed

Conversation

@Heliedan

@Heliedan Heliedan commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Follows #3530. Adds a "Check failed" event, off by default (a fourth row in the plugin's settings).

When a hash check finds that a complete torrent's data is missing or damaged, rTorrent stops the torrent and sets its message to Download registered as completed, but hash check returned unfinished chunks. The user only sees that in the web UI. With rTorrent 0.9.8 and 0.16.20, neither hash_failed nor hash_final_failed runs in that case, only hash_done.

hash_done runs after every check, including the one of each torrent rTorrent loads. So rTorrent tests the condition itself, and a check that passes starts no process:

branch=((and,((not,((d.complete)))),((match,((d.message)),".*hash check returned unfinished chunks.*")))),"execute.nothrow={...enqueue.sh...}"

Limits:

  • That message is rTorrent's own text, not a documented interface. It is the same in 0.9.8 and 0.16.20.
  • A torrent that stays damaged and stopped keeps the message, so each new recheck sends the event again.

Testing

  • TelegramTest.php: 39 methods (36 before). php-test.sh on PHP 7.4, 8.1, 8.5 and 32-bit 7.4: 212 files, 0 failures. Jest, PHP-CS-Fixer 3.95.27, PHPStan 2.2.9, eslint and shellcheck report nothing.

  • In containers, with rTorrent 0.9.8 (file limit 500000) and 0.16.20 and a fake Bot API: a Force recheck of an intact torrent and of one with a changed byte. It gave one "Check failed" message, for the damaged torrent, and nothing for the intact one. hash_done ran 6 times (4 loads, 2 rechecks) and started enqueue.sh once.

    With the template Check failed! {TORRENT}\nsize {SIZE} | label {LABEL} | ratio {RATIO}:

    Check failed! tgm-damaged.bin
    size 1.0 MiB | label Archive [2025] | ratio 0.000
    

Prepared with the help of an AI assistant.

When a hash check finds that a complete torrent's data is missing or
damaged, rTorrent stops the torrent and sets its message to "Download
registered as completed, but hash check returned unfinished chunks."
The user only sees it in the web UI. A "Check failed" event, off by
default, now sends a notification then. With rTorrent 0.9.8 and
0.16.20, neither hash_failed nor hash_final_failed runs in that case.

rTorrent runs hash_done after every check, including the one of each
torrent it loads. The handler tests d.complete and d.message in
rTorrent itself (branch, and, not, match), so a check that passes
starts no process; only a failed one runs enqueue.sh.
@xirvik
xirvik merged commit 7b13f04 into Novik:master Nov 10, 2026
12 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