* Initial seeding support added. Patch by Josef Drexler.

git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1058 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2008-05-05 19:16:26 +00:00
parent 3f64e8b1fa
commit e3fa31b6df
5 changed files with 26 additions and 10 deletions
+9 -1
View File
@@ -154,7 +154,7 @@ Close a torrent and its files.
<listitem><para>
Set the 'create/resize queued' flags on all files in a torrent. This
is necessary if the underlying files in a torrent have been deleted or
truncates, and thus rtorrent much recreate them.
truncated, and thus rtorrent must recreate them.
</para></listitem>
</varlistentry>
@@ -180,6 +180,14 @@ Call commands or change settings.
</para></listitem>
</varlistentry>
<varlistentry>
<term>^B</term>
<listitem><para>
Set download to perform initial seeding. Only use when
you are the first and only seeder so far for the download.
</para></listitem>
</varlistentry>
<varlistentry>
<term>+ | -</term>
<listitem><para>
+6 -5
View File
@@ -169,6 +169,8 @@ apply_d_connection_type(core::Download* download, const std::string& name) {
connType = torrent::Download::CONNECTION_LEECH;
else if (name == "seed")
connType = torrent::Download::CONNECTION_SEED;
else if (name == "initial_seed")
connType = torrent::Download::CONNECTION_INITIAL_SEED;
else
throw torrent::input_error("Unknown peer connection type selected.");
@@ -192,6 +194,8 @@ retrieve_d_connection_type(core::Download* download) {
return "leech";
case torrent::Download::CONNECTION_SEED:
return "seed";
case torrent::Download::CONNECTION_INITIAL_SEED:
return "initial_seed";
default:
return "unknown";
}
@@ -492,6 +496,8 @@ initialize_command_download() {
ADD_CD_VARIABLE_VALUE_PUBLIC("ignore_commands", "rtorrent", "ignore_commands");
ADD_CD_STRING_BI("connection_current", std::ptr_fun(&apply_d_connection_type), std::ptr_fun(&retrieve_d_connection_type));
ADD_CD_VARIABLE_STRING("connection_leech", "rtorrent", "connection_leech");
ADD_CD_VARIABLE_STRING("connection_seed", "rtorrent", "connection_seed");
ADD_CD_VALUE_BI("hashing_failed", std::mem_fun(&core::Download::set_hash_failed), std::mem_fun(&core::Download::is_hash_failed));
@@ -499,11 +505,6 @@ initialize_command_download() {
// logging support.
ADD_CD_STRING_BI("message", std::mem_fun(&core::Download::set_message), std::mem_fun(&core::Download::message));
add_copy_to_download("get_connection_leech", "d.get_connection_leech");
add_copy_to_download("set_connection_leech", "d.set_connection_leech");
add_copy_to_download("get_connection_seed", "d.get_connection_seed");
add_copy_to_download("set_connection_seed", "d.set_connection_seed");
ADD_CD_VALUE_MEM_BI("max_file_size", &core::Download::file_list, &torrent::FileList::set_max_file_size, &torrent::FileList::max_file_size);
ADD_CD_VALUE_MEM_BI("peers_min", &core::Download::connection_list, &torrent::ConnectionList::set_min_size, &torrent::ConnectionList::min_size);
+3 -4
View File
@@ -195,10 +195,6 @@ DownloadFactory::receive_success() {
if (!rtorrent->has_key_string("custom4")) rtorrent->insert_key("custom4", std::string());
if (!rtorrent->has_key_string("custom5")) rtorrent->insert_key("custom5", std::string());
// Move to 'rtorrent'.
rpc::call_command("d.set_connection_leech", m_variables["connection_leech"], rpc::make_target(download));
rpc::call_command("d.set_connection_seed", m_variables["connection_seed"], rpc::make_target(download));
rpc::call_command("d.set_uploads_max", rpc::call_command_void("get_max_uploads"), rpc::make_target(download));
rpc::call_command("d.set_peers_min", rpc::call_command_void("get_min_peers"), rpc::make_target(download));
rpc::call_command("d.set_peers_max", rpc::call_command_void("get_max_peers"), rpc::make_target(download));
@@ -352,6 +348,9 @@ DownloadFactory::initialize_rtorrent(Download* download, torrent::Object* rtorre
download->download()->file_list()->size_chunks()));
rtorrent->insert_preserve_copy("ignore_commands", (int64_t)0);
rtorrent->insert_preserve_type("connection_leech", m_variables["connection_leech"]);
rtorrent->insert_preserve_type("connection_seed", m_variables["connection_seed"]);
}
}
+4
View File
@@ -398,6 +398,10 @@ DownloadList::pause(Download* download, int flags) {
rpc::call_command("d.set_state_changed", cachedTime.seconds(), rpc::make_target(download));
rpc::call_command("d.set_state_counter", rpc::call_command_value("d.get_state_counter", rpc::make_target(download)), rpc::make_target(download));
// If initial seeding is complete, don't try it again when restarting.
if (download->is_done())
rpc::call_command("d.set_connection_seed", rpc::call_command_void("d.get_connection_current", rpc::make_target(download)), rpc::make_target(download));
// Save the state after all the slots, etc have been called so we
// include the modifications they may make.
//control->core()->download_store()->save(download);
+4
View File
@@ -76,6 +76,10 @@ ElementDownloadList::ElementDownloadList() :
"branch=d.get_ignore_commands=,"
"{d.set_ignore_commands=0, print=\"Torrent set to heed commands.\"},"
"{d.set_ignore_commands=1, print=\"Torrent set to ignore commands.\"}");
m_bindings['B'-'@']= sigc::bind(sigc::mem_fun(*this, &ElementDownloadList::receive_command),
"branch=d.is_active=,"
"{print=\"Cannot enable initial seeding on an active download.\"},"
"{d.set_connection_seed=initial_seed, print=\"Enabled initial seeding for the selected download.\"}");
m_bindings['U'] = sigc::bind(sigc::mem_fun(*this, &ElementDownloadList::receive_command), "d.delete_tied=; print=\"Cleared tied to file association for the selected download.\"");