snowyu / libtorrent

Automatically exported from code.google.com/p/libtorrent
Other
1 stars 0 forks source link

Pause after downloading metadata #650

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
As far as I understand, libtorrent starts to download all the files after 
.torrent files was downloaded. (see torrent::on_torrent_download)

But it would be useful if there would be an option to stop after downloading 
metadata so that user could select files to download.

Original issue reported on code.google.com by fl.lllj on 21 Jul 2014 at 3:06

GoogleCodeExporter commented 9 years ago
In qBittorrent we listen for the metadata_received_alert and pause the torrent 
immediately.
Of course, this isn't perfect. There is a delay between the torrent receiving 
metadata, alerting us and then pausing it.
link->http://libtorrent.org/reference-Alerts.html#metadata-received-alert

Original comment by hammered...@gmail.com on 25 Jul 2014 at 6:56

GoogleCodeExporter commented 9 years ago
what is the proposed API for this?

off hand, what I can think of is another flag to add_torrent_params 
flag_pause_on_metadata, which would pause the torrent immediately when the 
metadata was downloaded.

Another way of doing this right now is to set the file_priority field to a 
large vector of zeroes. 

Original comment by arvid.no...@gmail.com on 25 Jul 2014 at 9:02

GoogleCodeExporter commented 9 years ago
Actually I was thinking about such flag.
I can implement it and make a patch if there is no objections.

Original comment by fl.lllj on 25 Jul 2014 at 9:21

GoogleCodeExporter commented 9 years ago
I would prefer a default file priority value in add_torrent_params (which could 
be set to zero by the client) instead of pausing the torrent.

Original comment by webmas...@massaroddel.de on 26 Jul 2014 at 7:05

GoogleCodeExporter commented 9 years ago
@fl.lllj: please do. It seems like a useful flag.

@webmaster@massaroddel.de: You almost have this now. you can set the file 
priority vector to zeroes. The only issue is that if the torrent turn out to 
have more files than you have zeroes in there, those files will still have 
priority 1. Other gotchas are the disconnect_redundant peers will cause all the 
peers to be disconnected right away anyway, because nobody is interested in you 
and you're no interested in anyone else.

Original comment by arvid.no...@gmail.com on 28 Jul 2014 at 12:42

GoogleCodeExporter commented 9 years ago
Sorry for the late response. I wasn't subscribed to this issue.
I agree with an addition to add_torrent_params.

Original comment by hammered...@gmail.com on 29 Dec 2014 at 8:59

GoogleCodeExporter commented 9 years ago
There is a good solution that already exists in 0.16, I just tested it 
myself... metadata was received, and 0 pieces downloaded :)

in add_torrent_params set flag_upload_mode

"If set, the torrent will be initialized in upload-mode, which means it will 
not make any piece requests. This state is typically entered on disk I/O 
errors, and if the torrent is also auto managed, it will be taken out of this 
state periodically. This mode can be used to avoid race conditions when 
adjusting priorities of pieces before allowing the torrent to start 
downloading."

I have been looking to do this myself... since I had 0.15 package installed I 
was doing the method of just waiting for metadata_received alert and pausing, 
tho of course like hammered says, that isn't perfect since download may start 
in between the alert and doing pause. Thankfully I decided to update to 0.16 
and found the new flag :)

Original comment by dda...@gmail.com on 15 Jan 2015 at 10:47

GoogleCodeExporter commented 9 years ago
Hmm, interesting idea @dda
PS: You should also unset flag_auto_managed
PS2: libtorrent 1.0.x is already out and considered stable(in case you missed 
that).

Original comment by hammered...@gmail.com on 16 Jan 2015 at 8:47