transmission / transmission

Official Transmission BitTorrent client repository
https://transmissionbt.com
Other
12.13k stars 1.21k forks source link

Don't check paused (or never started) torrents for completion, or equivalent #4219

Open dradetsky opened 1 year ago

dradetsky commented 1 year ago

What is the issue?

Let's say I add a torrent with many, many files, most of which aren't of interest to me. I just want a few of the files in the torrent. So I mark all the files as priority=off using tremc (or some equivalent), then go to select the specific files I want to increase their priority. But now since the number of bytes I have is greater or equal to the number of bytes I want (0, since I just marked all files as off, the daemon considers the torrent complete and moves its root dir from my incomplete files dir to my complete files dir. I can move it back to the incomplete files dir after I mark a few files to actually be downloaded, but now the daemon won't move the files back to the completed files dir when it's done downloading the few files I asked for (since as far as it's concerned I just manually moved a completed torrent's files from the completed dir to some other dir, and the fact that this happens to be the incomplete files dir doesn't mean anything).

Attempting to find a workaround, I think: This must be happening because I'm adding torrents in started state. I should set the daemon to add new torrents in paused state, mess with them, then start the torrents manually. However, this does not fix the issue. The torrent is still moved to the complete files dir (and probably, hook scripts are run, although I don't currently have any hook scripts attached to test this).

Intuitively, I would think that what we want is to not check if a torrent is complete (and thus trigger post-completion work like moving files & running hook scripts) if that torrent has never been started. However, it's possible that it isn't that easy. For example, maybe libtransmission has no concept of "never started", just "not started" (i.e. paused), and maybe adding this new state would be complicated.

Another option might be to not check paused torrents, however I haven't thought about whether this might cause other issues.

A third option might be to not limit the completion check to once per torrent. Instead, any time a torrent transitions from wanting 1 or more bytes to not wanting additional bytes, we go through the completion logic. We move it from incomplete to complete (if applicable), we fire the hooks, etc. This might also be very complicated and/or a bad idea for reasons I haven't thought of.

Apologies if this sounds kind of dumb. I've barely looked at the code & haven't done serious c++ dev in years, so I'm just kind of going off the way I assume it must work. Maybe it's nothing like that, idk.

Which application of Transmission?

transmission-daemon

Which version of Transmission?

3.0 (bb6b5a062e)

killemov commented 1 year ago

But now since the number of bytes I have is greater or equal to the number of bytes I want ...

How can you HAVE any bytes when you have not started downloading yet?

When adding a torrent Transmission-daemon automatically puts it in the check (/waiting) state to pick up any previously downloaded files. AFAIK that is the only moment it does the checking of content automatically. A nice feature could be to configure this, but in general this is a good thing. The actual problem is what Transmission-daemon deems complete (no files selected) and the attached processing that comes with that.

dradetsky commented 1 year ago

@killemov

How can you HAVE any bytes when you have not started downloading yet?

I can't. But if I mark all files as off, the number of bytes I want is zero. So the number of bytes I have (zero) is greater than or equal to the number of bytes I want. So the torrent is deemed complete, and on-complete processing is performed. Which I don't want.

killemov commented 1 year ago

... or equal to the number of bytes I want.

You select 0 bytes, you download 0 bytes, torrent complete as designed. You obviously need a special case of a completed torrent which has a sizeWhenDone of 0. You cannot select a sizeWhenDone of -1.