Skip to content

datadir: check reload refusals before erasing - #3569

Merged
xirvik merged 1 commit into
Novik:masterfrom
IvanShift:up/datadir-check-reload-refusals
Nov 22, 2026
Merged

xirvik merged 1 commit into
Novik:masterfrom
IvanShift:up/datadir-check-reload-refusals

Conversation

@IvanShift

Copy link
Copy Markdown
Contributor

Why

Fast resume erases a download and only then asks rTorrent::sendTorrent() to load it again. When the loader refuses an addition or directory, the download is gone; when the saved .torrent is another torrent, that torrent takes its place.

What changes

  • Before d.erase, check the torrent's hash, additions and directory using the loader's existing rules.
  • On refusal, log the reason with the hash and change the directory the existing slow way, which keeps the download.

Compatibility

  • Tested on f8962e3 plus this change with PHP 7.4, 8.1 and 8.5; live on rTorrent 0.9.8 and 0.16.28, both a successful and a refused reload.
  • A torrent whose info dictionary does not re-encode to the same bytes now takes the slow path, because the reload would change its hash.
  • Failures of d.stop, d.close or d.set_directory before this check, and a load that fails after the erase, are not covered.

How to test

  • Automated: cd tests && bash php-test.sh; SetDirFastResumeSessionTest::testDifferentTorrentIsNotErased fails on f8962e3 and passes with this change.
  • Manual:
    1. On rTorrent 0.9.8, make a test download's saved session .torrent unreadable and tie the download to another torrent's file (0.16.28 rewrites the session copy at the stop, so use the automated test there).
    2. Change its directory with fast resume. Before: the download is erased and the other torrent is loaded. After: it stays, with the new directory, and the log names the hash and the reason.

Fast resume erased the download and only then asked the loader, so a
refused addition or directory lost it, and a different .torrent
replaced it. Ask first; a refusal is logged and takes the slow path.
@xirvik
xirvik merged commit 3bd03cb into Novik:master Nov 22, 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