merged RC_1_1 into master
This commit is contained in:
commit
583082a3a0
|
@ -42,6 +42,7 @@
|
|||
* resume data no longer has timestamps of files
|
||||
* require C++11 to build libtorrent
|
||||
|
||||
* add trackers from add_torrent_params/magnet links to separate tiers
|
||||
* fix resumedata check issue with files with priority 0
|
||||
* deprecated mmap_cache feature
|
||||
* add utility function for generating peer ID fingerprint
|
||||
|
|
|
@ -65,6 +65,16 @@ void bind_session_settings()
|
|||
#endif
|
||||
;
|
||||
|
||||
enum_<settings_pack::proxy_type_t>("proxy_type_t")
|
||||
.value("none", settings_pack::none)
|
||||
.value("socks4", settings_pack::socks4)
|
||||
.value("socks5", settings_pack::socks5)
|
||||
.value("socks5_pw", settings_pack::socks5_pw)
|
||||
.value("http", settings_pack::http)
|
||||
.value("http_pw", settings_pack::http_pw)
|
||||
.value("i2p_proxy", settings_pack::i2p_proxy)
|
||||
;
|
||||
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
enum_<proxy_settings::proxy_type>("proxy_type")
|
||||
.value("none", proxy_settings::none)
|
||||
|
|
|
@ -183,12 +183,19 @@ namespace libtorrent
|
|||
// parse trackers out of the magnet link
|
||||
std::string::size_type pos = std::string::npos;
|
||||
std::string url = url_has_argument(uri, "tr", &pos);
|
||||
int tier = 0;
|
||||
while (pos != std::string::npos)
|
||||
{
|
||||
// since we're about to assign tiers to the trackers, make sure the two
|
||||
// vectors are aligned
|
||||
if (p.tracker_tiers.size() != p.trackers.size())
|
||||
p.tracker_tiers.resize(p.trackers.size(), 0);
|
||||
|
||||
error_code e;
|
||||
url = unescape_string(url, e);
|
||||
if (e) continue;
|
||||
p.trackers.push_back(url);
|
||||
p.tracker_tiers.push_back(tier++);
|
||||
pos = uri.find("&tr=", pos);
|
||||
if (pos == std::string::npos) break;
|
||||
pos += 4;
|
||||
|
|
|
@ -175,7 +175,7 @@ bool should_print(lt::alert* a)
|
|||
return true;
|
||||
}
|
||||
}
|
||||
alert const* wait_for_alert(lt::session& ses, int type, char const* name)
|
||||
alert const* wait_for_alert(lt::session& ses, int type, char const* name, int num)
|
||||
{
|
||||
time_point end_time = libtorrent::clock_type::now() + seconds(10);
|
||||
while (true)
|
||||
|
@ -195,12 +195,13 @@ alert const* wait_for_alert(lt::session& ses, int type, char const* name)
|
|||
std::printf("%s: %s: [%s] %s\n", time_now_string(), name
|
||||
, a->what(), a->message().c_str());
|
||||
}
|
||||
if (a->type() == type && !ret)
|
||||
if (a->type() == type)
|
||||
{
|
||||
ret = a;
|
||||
--num;
|
||||
}
|
||||
}
|
||||
if (ret) return ret;
|
||||
if (num == 0) return ret;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ EXPORT libtorrent::sha1_hash to_hash(char const* s);
|
|||
EXPORT std::map<std::string, std::int64_t> get_counters(libtorrent::session& s);
|
||||
|
||||
EXPORT libtorrent::alert const* wait_for_alert(
|
||||
libtorrent::session& ses, int type, char const* name = "");
|
||||
libtorrent::session& ses, int type, char const* name = "", int num = 1);
|
||||
|
||||
EXPORT void print_ses_rate(float time
|
||||
, libtorrent::torrent_status const* st1
|
||||
|
|
|
@ -150,6 +150,8 @@ TORRENT_TEST(magnet)
|
|||
|
||||
trackers = t2.trackers();
|
||||
TEST_EQUAL(trackers.size(), 2);
|
||||
TEST_EQUAL(trackers[0].tier, 0);
|
||||
TEST_EQUAL(trackers[1].tier, 1);
|
||||
|
||||
p.url = "magnet:"
|
||||
"?tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80"
|
||||
|
@ -166,16 +168,19 @@ TORRENT_TEST(magnet)
|
|||
if (trackers.size() > 0)
|
||||
{
|
||||
TEST_EQUAL(trackers[0].url, "udp://tracker.openbittorrent.com:80");
|
||||
TEST_EQUAL(trackers[0].tier, 0);
|
||||
std::printf("1: %s\n", trackers[0].url.c_str());
|
||||
}
|
||||
if (trackers.size() > 1)
|
||||
{
|
||||
TEST_EQUAL(trackers[1].url, "udp://tracker.publicbt.com:80");
|
||||
TEST_EQUAL(trackers[1].tier, 1);
|
||||
std::printf("2: %s\n", trackers[1].url.c_str());
|
||||
}
|
||||
if (trackers.size() > 2)
|
||||
{
|
||||
TEST_EQUAL(trackers[2].url, "udp://tracker.ccc.de:80");
|
||||
TEST_EQUAL(trackers[2].tier, 2);
|
||||
std::printf("3: %s\n", trackers[2].url.c_str());
|
||||
}
|
||||
|
||||
|
|
|
@ -115,11 +115,8 @@ void run_until(io_service& ios, bool const& done)
|
|||
|
||||
void nop() {}
|
||||
|
||||
std::shared_ptr<default_storage> setup_torrent(file_storage& fs
|
||||
, file_pool& fp
|
||||
, std::vector<char>& buf
|
||||
, std::string const& test_path
|
||||
, aux::session_settings& set)
|
||||
std::shared_ptr<torrent_info> setup_torrent_info(file_storage& fs
|
||||
, std::vector<char>& buf)
|
||||
{
|
||||
fs.add_file(combine_path("temp_storage", "test1.tmp"), 8);
|
||||
fs.add_file(combine_path("temp_storage", combine_path("folder1", "test2.tmp")), 8);
|
||||
|
@ -144,6 +141,17 @@ std::shared_ptr<default_storage> setup_torrent(file_storage& fs
|
|||
, ec.message().c_str());
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
std::shared_ptr<default_storage> setup_torrent(file_storage& fs
|
||||
, file_pool& fp
|
||||
, std::vector<char>& buf
|
||||
, std::string const& test_path
|
||||
, aux::session_settings& set)
|
||||
{
|
||||
std::shared_ptr<torrent_info> info = setup_torrent_info(fs, buf);
|
||||
|
||||
storage_params p;
|
||||
p.files = &fs;
|
||||
p.pool = &fp;
|
||||
|
@ -739,6 +747,68 @@ bool got_file_rename_alert(alert const* a)
|
|||
|| alert_cast<libtorrent::file_rename_failed_alert>(a);
|
||||
}
|
||||
|
||||
TORRENT_TEST(rename_file)
|
||||
{
|
||||
std::vector<char> buf;
|
||||
file_storage fs;
|
||||
std::shared_ptr<torrent_info> info = setup_torrent_info(fs, buf);
|
||||
|
||||
const int mask = alert::all_categories
|
||||
& ~(alert::performance_warning
|
||||
| alert::stats_notification);
|
||||
|
||||
settings_pack pack;
|
||||
pack.set_bool(settings_pack::enable_lsd, false);
|
||||
pack.set_bool(settings_pack::enable_natpmp, false);
|
||||
pack.set_bool(settings_pack::enable_upnp, false);
|
||||
pack.set_bool(settings_pack::enable_dht, false);
|
||||
pack.set_int(settings_pack::alert_mask, mask);
|
||||
pack.set_bool(settings_pack::disable_hash_checks, true);
|
||||
lt::session ses(pack);
|
||||
|
||||
add_torrent_params p;
|
||||
p.ti = info;
|
||||
p.save_path = ".";
|
||||
error_code ec;
|
||||
torrent_handle h = ses.add_torrent(p, ec);
|
||||
|
||||
// make it a seed
|
||||
std::vector<char> tmp(info->piece_length());
|
||||
for (int i = 0; i < info->num_pieces(); ++i)
|
||||
h.add_piece(i, &tmp[0]);
|
||||
|
||||
// wait for the files to have been written
|
||||
alert const* pf = wait_for_alert(ses, piece_finished_alert::alert_type, "ses", info->num_pieces());
|
||||
TEST_CHECK(pf);
|
||||
|
||||
// now rename them. This is the test
|
||||
for (int i = 0; i < info->num_files(); ++i)
|
||||
{
|
||||
std::string name = fs.file_path(i);
|
||||
h.rename_file(i, "__" + name);
|
||||
}
|
||||
|
||||
// wait fir the files to have been renamed
|
||||
alert const* fra = wait_for_alert(ses, file_renamed_alert::alert_type, "ses", info->num_files());
|
||||
TEST_CHECK(fra);
|
||||
|
||||
TEST_CHECK(exists("__" + info->name()));
|
||||
|
||||
h.save_resume_data();
|
||||
alert const* ra = wait_for_alert(ses, save_resume_data_alert::alert_type);
|
||||
TEST_CHECK(ra);
|
||||
if (!ra) return;
|
||||
entry resume = *alert_cast<save_resume_data_alert>(ra)->resume_data;
|
||||
|
||||
std::cerr << resume.to_string() << "\n";
|
||||
|
||||
entry::list_type files = resume.dict().find("mapped_files")->second.list();
|
||||
for (entry::list_type::iterator i = files.begin(); i != files.end(); ++i)
|
||||
{
|
||||
TEST_CHECK(i->string().substr(0, 2) == "__");
|
||||
}
|
||||
}
|
||||
|
||||
void test_rename_file_fastresume(bool test_deprecated)
|
||||
{
|
||||
std::string test_path = current_working_directory();
|
||||
|
|
Loading…
Reference in New Issue