[Libtorrent-devel] how to open and start a download in source code
Jari Sundell
sundell.software at gmail.com
Wed Dec 3 15:22:16 UTC 2008
Nemo wrote:
> i want get "auto open/close torrent" function via modify libtorrent
> source code.
>
> i can auto stop a torrent now, when erase a peer ( in
> ConnectionList::iterator ConnectionList::erase(iterator pos, int flags)
> ) , check size of connectionlist, close (Download::stop() and
> Download::close()) torrent when size is 0.
>
> libtorent will throw a handshake error when libtorrent get a request of
> handshake and the torrent requested is not active in original source
> code, i modify code here hope open the torrent complete handshake and
> download instead of throw error.
> i got problem here, i can open a torrent via call Download::open(), but
> i got a "Tried to start an unchecked download" error if call
> Download::start() directly and skip Download::hash_check(). i do not
> know how to use hash_check() here, who can give me some suggestion how
> to open and start a download, i am a newbie and sorry for my poor english.
You need to ensure resume data is loaded to avoid rehashing the entire
torrent, so you can't just call hash_check. In
rtorrent/src/core/manager.cc:491 you see how the torrent gets hash checked.
However, doing this inside libtorrent isn't really recommended, as the
client probably won't entirely like having these things happen
out-of-order. I'd recommend adding signals to torrent::Download and call
the proper commands through those.
Jari Sundell
More information about the Libtorrent-devel
mailing list