diff --git a/doc/rtorrent.1.xml b/doc/rtorrent.1.xml index fd72dab8..e84a21b4 100644 --- a/doc/rtorrent.1.xml +++ b/doc/rtorrent.1.xml @@ -495,7 +495,7 @@ Open the listening port at a random position in the port range. check_hash = yes | no -Perform hash check on finished downloads. +Perform hash check on torrents that have finished downloading. diff --git a/src/core/download_factory.cc b/src/core/download_factory.cc index 7915fd83..d312a38a 100644 --- a/src/core/download_factory.cc +++ b/src/core/download_factory.cc @@ -259,7 +259,7 @@ DownloadFactory::initialize_rtorrent(Download* download, torrent::Object* rtorre download->tracker_list()->set_key(rtorrent->get_key("key").as_value()); } else { - download->tracker_list()->set_key(rand() % (std::numeric_limits::max() - 1) + 1); + download->tracker_list()->set_key(random() % (std::numeric_limits::max() - 1) + 1); rtorrent->insert_key("key", download->tracker_list()->key()); } diff --git a/src/option_handler_rules.cc b/src/option_handler_rules.cc index ffc6a91a..e1296de8 100644 --- a/src/option_handler_rules.cc +++ b/src/option_handler_rules.cc @@ -56,6 +56,7 @@ #include #include "core/download.h" +#include "core/download_list.h" #include "core/download_store.h" #include "core/manager.h" #include "core/scheduler.h" @@ -70,6 +71,11 @@ #include "option_handler_rules.h" #include "command_scheduler.h" +namespace core { + extern void + path_expand(std::vector* paths, const std::string& pattern); +} + void apply_hash_read_ahead(__UNUSED Control* m, int arg) { torrent::set_hash_read_ahead(arg << 20); @@ -111,6 +117,22 @@ apply_load_start_verbose(Control* m, const std::string& arg) { m->core()->try_create_download_expand(arg, true, true, true); } +void +apply_start_tied(Control* m, const std::string& arg) { + std::vector paths; + paths.reserve(256); + + core::path_expand(&paths, arg); + + for (std::vector::iterator itr = paths.begin(); itr != paths.end(); ++itr) { + core::DownloadList::iterator dItr = std::find_if(m->core()->download_list()->begin(), m->core()->download_list()->end(), + rak::equal(*itr, rak::bind2nd(std::mem_fun(&core::Download::variable_string), "tied_to_file"))); + + if (dItr != m->core()->download_list()->end()) + m->core()->download_list()->start(*dItr); + } +} + void apply_stop_untied(Control* m) { core::Manager::DListItr itr = m->core()->download_list()->begin(); @@ -121,7 +143,7 @@ apply_stop_untied(Control* m) { rak::file_stat fs; if (!fs.update(rak::path_expand((*itr)->variable_string("tied_to_file")))) { - (*itr)->variable()->set("tied_to_file", std::string()); +// (*itr)->variable()->set("tied_to_file", std::string()); m->core()->download_list()->stop(*itr); } @@ -139,7 +161,7 @@ apply_close_untied(Control* m) { rak::file_stat fs; if (!fs.update(rak::path_expand((*itr)->variable_string("tied_to_file")))) { - (*itr)->variable()->set("tied_to_file", std::string()); +// (*itr)->variable()->set("tied_to_file", std::string()); m->core()->download_list()->close(*itr); } @@ -157,7 +179,7 @@ apply_remove_untied(Control* m) { rak::file_stat fs; if (!fs.update(rak::path_expand((*itr)->variable_string("tied_to_file")))) { - (*itr)->variable()->set("tied_to_file", std::string()); +// (*itr)->variable()->set("tied_to_file", std::string()); m->core()->download_list()->stop(*itr); itr = m->core()->download_list()->erase(itr); @@ -471,9 +493,12 @@ initialize_option_handler(Control* c) { variables->insert("load_verbose", new utils::VariableStringSlot(rak::value_fn(std::string()), rak::bind_ptr_fn(&apply_load_verbose, c))); variables->insert("load_start", new utils::VariableStringSlot(rak::value_fn(std::string()), rak::bind_ptr_fn(&apply_load_start, c))); variables->insert("load_start_verbose", new utils::VariableStringSlot(rak::value_fn(std::string()), rak::bind_ptr_fn(&apply_load_start_verbose, c))); + + variables->insert("start_tied", new utils::VariableStringSlot(rak::value_fn(std::string()), rak::bind_ptr_fn(&apply_start_tied, c))); variables->insert("stop_untied", new utils::VariableVoidSlot(rak::bind_ptr_fn(&apply_stop_untied, c))); variables->insert("close_untied", new utils::VariableVoidSlot(rak::bind_ptr_fn(&apply_close_untied, c))); variables->insert("remove_untied", new utils::VariableVoidSlot(rak::bind_ptr_fn(&apply_remove_untied, c))); + variables->insert("close_low_diskspace", new utils::VariableValueSlot(rak::value_fn(int64_t()), rak::bind_ptr_fn(&apply_close_low_diskspace, c))); variables->insert("stop_on_ratio", new utils::VariableStringSlot(rak::value_fn(std::string()), rak::bind_ptr_fn(&apply_stop_on_ratio, c)));