fix bug in dict_to_torrent_params in python binding
This commit is contained in:
parent
2330520c51
commit
e71ead49ed
|
@ -12,7 +12,8 @@ using namespace boost::python;
|
|||
using namespace libtorrent;
|
||||
|
||||
extern void dict_to_add_torrent_params(dict params
|
||||
, add_torrent_params& p, std::vector<char>& rd);
|
||||
, add_torrent_params& p, std::vector<char>& rd
|
||||
, std::list<std::string>& storage);
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -21,7 +22,8 @@ namespace {
|
|||
add_torrent_params p;
|
||||
|
||||
std::vector<char> resume_buf;
|
||||
dict_to_add_torrent_params(params, p, resume_buf);
|
||||
std::list<std::string> string_storage;
|
||||
dict_to_add_torrent_params(params, p, resume_buf, string_storage);
|
||||
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
return add_magnet_uri(s, uri, p);
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
// subject to the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <boost/python.hpp>
|
||||
#include <libtorrent/session.hpp>
|
||||
#include <libtorrent/settings.hpp> // for bencode_map_entry
|
||||
|
@ -145,7 +147,8 @@ namespace
|
|||
#endif
|
||||
}
|
||||
|
||||
void dict_to_add_torrent_params(dict params, add_torrent_params& p, std::vector<char>& rd)
|
||||
void dict_to_add_torrent_params(dict params, add_torrent_params& p
|
||||
, std::vector<char>& rd, std::list<std::string>& string_storage)
|
||||
{
|
||||
// torrent_info objects are always held by an intrusive_ptr in the python binding
|
||||
if (params.has_key("ti"))
|
||||
|
@ -154,16 +157,15 @@ namespace
|
|||
std::string url;
|
||||
if (params.has_key("tracker_url"))
|
||||
{
|
||||
url = extract<std::string>(params["tracker_url"]);
|
||||
p.tracker_url = url.c_str();
|
||||
string_storage.push_back(extract<std::string>(params["tracker_url"]));
|
||||
p.tracker_url = string_storage.back().c_str();
|
||||
}
|
||||
if (params.has_key("info_hash"))
|
||||
p.info_hash = extract<sha1_hash>(params["info_hash"]);
|
||||
std::string name;
|
||||
if (params.has_key("name"))
|
||||
{
|
||||
name = extract<std::string>(params["name"]);
|
||||
p.name = name.c_str();
|
||||
string_storage.push_back(extract<std::string>(params["name"]));
|
||||
p.name = string_storage.back().c_str();
|
||||
}
|
||||
p.save_path = extract<std::string>(params["save_path"]);
|
||||
|
||||
|
@ -217,7 +219,8 @@ namespace
|
|||
{
|
||||
add_torrent_params p;
|
||||
std::vector<char> resume_buf;
|
||||
dict_to_add_torrent_params(params, p, resume_buf);
|
||||
std::list<std::string> string_buf;
|
||||
dict_to_add_torrent_params(params, p, resume_buf, string_buf);
|
||||
|
||||
allow_threading_guard guard;
|
||||
|
||||
|
@ -229,7 +232,9 @@ namespace
|
|||
#endif
|
||||
}
|
||||
|
||||
void dict_to_feed_settings(dict params, feed_settings& feed, std::vector<char>& resume_buf)
|
||||
void dict_to_feed_settings(dict params, feed_settings& feed
|
||||
, std::vector<char>& resume_buf
|
||||
, std::list<std::string>& string_storage)
|
||||
{
|
||||
if (params.has_key("auto_download"))
|
||||
feed.auto_download = extract<bool>(params["auto_download"]);
|
||||
|
@ -238,7 +243,8 @@ namespace
|
|||
if (params.has_key("url"))
|
||||
feed.url = extract<std::string>(params["url"]);
|
||||
if (params.has_key("add_args"))
|
||||
dict_to_add_torrent_params(dict(params["add_args"]), feed.add_args, resume_buf);
|
||||
dict_to_add_torrent_params(dict(params["add_args"]), feed.add_args
|
||||
, resume_buf, string_storage);
|
||||
}
|
||||
|
||||
feed_handle add_feed(session& s, dict params)
|
||||
|
@ -249,7 +255,8 @@ namespace
|
|||
// this static here is a bit of a hack. It will
|
||||
// probably work for the most part
|
||||
static std::vector<char> resume_buf;
|
||||
dict_to_feed_settings(params, feed, resume_buf);
|
||||
std::list<std::string> string_storage;
|
||||
dict_to_feed_settings(params, feed, resume_buf, string_storage);
|
||||
|
||||
return s.add_feed(feed);
|
||||
}
|
||||
|
@ -295,7 +302,8 @@ namespace
|
|||
|
||||
feed_settings feed;
|
||||
static std::vector<char> resume_buf;
|
||||
dict_to_feed_settings(sett, feed, resume_buf);
|
||||
std::list<std::string> string_storage;
|
||||
dict_to_feed_settings(sett, feed, resume_buf, string_storage);
|
||||
h.set_settings(feed);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue