mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-11 04:32:30 +00:00
* Added "d_delete_tied" command.
* Moved CommandScheduler into src/rpc. * Fixed a bug in the "download_list" command. * Partial cleanup of the tracker list. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@924 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -125,59 +125,6 @@ Download::receive_storage_error(std::string msg) {
|
||||
m_message = "Storage error: [" + msg + "]";
|
||||
}
|
||||
|
||||
Download::download_type::ConnectionType
|
||||
Download::string_to_connection_type(const std::string& name) {
|
||||
// Return default if the name isn't found.
|
||||
if (name == "leech")
|
||||
return download_type::CONNECTION_LEECH;
|
||||
else if (name == "seed")
|
||||
return download_type::CONNECTION_SEED;
|
||||
else
|
||||
throw torrent::input_error("Unknown peer connection type selected: \"" + name + "\"");
|
||||
}
|
||||
|
||||
const char*
|
||||
Download::connection_type_to_string(download_type::ConnectionType t) {
|
||||
switch (t) {
|
||||
case download_type::CONNECTION_LEECH:
|
||||
return "leech";
|
||||
case download_type::CONNECTION_SEED:
|
||||
return "seed";
|
||||
default:
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t
|
||||
Download::string_to_priority(const std::string& name) {
|
||||
if (name == "off")
|
||||
return 0;
|
||||
else if (name == "low")
|
||||
return 1;
|
||||
else if (name == "normal")
|
||||
return 2;
|
||||
else if (name == "high")
|
||||
return 3;
|
||||
else
|
||||
throw torrent::input_error("Could not convert string to priority.");
|
||||
}
|
||||
|
||||
const char*
|
||||
Download::priority_to_string(uint32_t p) {
|
||||
switch (p) {
|
||||
case 0:
|
||||
return "off";
|
||||
case 1:
|
||||
return "low";
|
||||
case 2:
|
||||
return "normal";
|
||||
case 3:
|
||||
return "high";
|
||||
default:
|
||||
throw torrent::input_error("Priority out of range.");
|
||||
}
|
||||
}
|
||||
|
||||
float
|
||||
Download::distributed_copies() const {
|
||||
const uint8_t* avail = m_download.chunks_seen();
|
||||
|
||||
@@ -104,17 +104,6 @@ public:
|
||||
|
||||
bool operator == (const std::string& str) const;
|
||||
|
||||
void set_connection_type(const std::string& t) { m_download.set_connection_type(string_to_connection_type(t)); }
|
||||
|
||||
static connection_type string_to_connection_type(const std::string& name);
|
||||
static const char* connection_type_to_string(connection_type t);
|
||||
|
||||
const char* connection_current() const { return connection_type_to_string(m_download.connection_type()); }
|
||||
void set_connection_current(const std::string& t) { return m_download.set_connection_type(string_to_connection_type(t.c_str())); }
|
||||
|
||||
static uint32_t string_to_priority(const std::string& name);
|
||||
static const char* priority_to_string(uint32_t p);
|
||||
|
||||
float distributed_copies() const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -352,9 +352,9 @@ DownloadList::resume(Download* download) {
|
||||
rpc::call_command_d("set_d_state_changed", download, cachedTime.seconds());
|
||||
|
||||
if (download->is_done()) {
|
||||
download->set_connection_type(rpc::call_command_d_string("get_d_connection_seed", download));
|
||||
rpc::call_command_d("set_d_connection_current", download, rpc::call_command_d_void("get_d_connection_seed", download));
|
||||
} else {
|
||||
download->set_connection_type(rpc::call_command_d_string("get_d_connection_leech", download));
|
||||
rpc::call_command_d("set_d_connection_current", download, rpc::call_command_d_void("get_d_connection_leech", download));
|
||||
|
||||
// For the moment, clear the resume data so we force hash-check
|
||||
// on non-complete downloads after a crash. This shouldn't be
|
||||
@@ -536,7 +536,7 @@ DownloadList::confirm_finished(Download* download) {
|
||||
|
||||
rpc::call_command_d("set_d_complete", download, (int64_t)1);
|
||||
|
||||
download->set_connection_type(rpc::call_command_d_string("get_d_connection_seed", download));
|
||||
rpc::call_command_d("set_d_connection_current", download, rpc::call_command_d_void("get_d_connection_seed", download));
|
||||
download->set_priority(download->priority());
|
||||
|
||||
if (rpc::call_command_d_value("get_d_min_peers", download) == rpc::call_command_value("get_min_peers") && rpc::call_command_value("get_min_peers_seed") >= 0)
|
||||
|
||||
+1
-23
@@ -165,22 +165,6 @@ Manager::handshake_log(const sockaddr* sa, int msg, int err, const torrent::Hash
|
||||
}
|
||||
}
|
||||
|
||||
// Hmm... find some better place for all this.
|
||||
void
|
||||
Manager::delete_tied(Download* download) {
|
||||
const std::string& tie = rpc::call_command_d_string("get_d_tied_to_file", download);
|
||||
|
||||
// This should be configurable, need to wait for the variable
|
||||
// thingie to be implemented.
|
||||
if (tie.empty())
|
||||
return;
|
||||
|
||||
if (::unlink(rak::path_expand(tie).c_str()) == -1)
|
||||
push_log("Could not unlink tied file: " + std::string(rak::error_number::current().c_str()));
|
||||
|
||||
rpc::call_command_d("set_d_tied_to_file", download, std::string());
|
||||
}
|
||||
|
||||
Manager::Manager() :
|
||||
m_hashingView(NULL),
|
||||
|
||||
@@ -240,7 +224,7 @@ Manager::initialize_second() {
|
||||
m_downloadList->slot_map_insert()["1_connect_storage_log"] = sigc::bind(sigc::ptr_fun(&connect_signal_storage_log), sigc::mem_fun(m_logComplete, &Log::push_front));
|
||||
m_downloadList->slot_map_insert()["1_connect_tracker_dump"] = sigc::bind(sigc::ptr_fun(&connect_signal_tracker_dump), sigc::ptr_fun(&receive_tracker_dump));
|
||||
|
||||
m_downloadList->slot_map_erase()["9_delete_tied"] = sigc::mem_fun(this, &Manager::delete_tied);
|
||||
m_downloadList->slot_map_erase()["9_delete_tied"] = sigc::bind<0>(&rpc::call_command_d_v_void, "d_delete_tied");
|
||||
|
||||
torrent::connection_manager()->set_signal_handshake_log(sigc::mem_fun(this, &Manager::handshake_log));
|
||||
}
|
||||
@@ -260,12 +244,6 @@ Manager::cleanup() {
|
||||
|
||||
void
|
||||
Manager::shutdown(bool force) {
|
||||
// This doesn't trigger a compiler error on gcc-3.4.5 for some reason.
|
||||
// if (!force)
|
||||
// std::for_each(m_downloadList->begin(), m_downloadList->end(), std::bind1st(std::mem_fun(&DownloadList::pause), &m_downloadList));
|
||||
// else
|
||||
// std::for_each(m_downloadList->begin(), m_downloadList->end(), std::bind1st(std::mem_fun(&DownloadList::close), &m_downloadList));
|
||||
|
||||
if (!force)
|
||||
std::for_each(m_downloadList->begin(), m_downloadList->end(), std::bind1st(std::mem_fun(&DownloadList::pause), m_downloadList));
|
||||
else
|
||||
|
||||
@@ -100,8 +100,6 @@ public:
|
||||
void try_create_download(const std::string& uri, bool start, bool printLog = true, bool tied = false);
|
||||
void try_create_download_expand(const std::string& uri, bool start, bool printLog = true, bool tied = false);
|
||||
|
||||
void delete_tied(Download* d);
|
||||
|
||||
private:
|
||||
void create_http(const std::string& uri);
|
||||
void create_final(std::istream* s);
|
||||
|
||||
Reference in New Issue
Block a user