diff --git a/doc/rtorrent.1.xml b/doc/rtorrent.1.xml
index a7b2910b..ccea8875 100644
--- a/doc/rtorrent.1.xml
+++ b/doc/rtorrent.1.xml
@@ -154,7 +154,7 @@ Close a torrent and its files.
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.
@@ -180,6 +180,14 @@ Call commands or change settings.
+
+ ^B
+
+Set download to perform initial seeding. Only use when
+you are the first and only seeder so far for the download.
+
+
+
+ | -
diff --git a/src/command_download.cc b/src/command_download.cc
index f049e575..02415bf4 100644
--- a/src/command_download.cc
+++ b/src/command_download.cc
@@ -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);
diff --git a/src/core/download_factory.cc b/src/core/download_factory.cc
index c8ab0601..752b5cbd 100644
--- a/src/core/download_factory.cc
+++ b/src/core/download_factory.cc
@@ -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"]);
}
}
diff --git a/src/core/download_list.cc b/src/core/download_list.cc
index 0ba1e937..3a0f268d 100644
--- a/src/core/download_list.cc
+++ b/src/core/download_list.cc
@@ -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);
diff --git a/src/ui/element_download_list.cc b/src/ui/element_download_list.cc
index 44204af7..378aaa70 100644
--- a/src/ui/element_download_list.cc
+++ b/src/ui/element_download_list.cc
@@ -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.\"");