diff --git a/doc/rtorrent.1.xml b/doc/rtorrent.1.xml index 69580e9a..376ce775 100644 --- a/doc/rtorrent.1.xml +++ b/doc/rtorrent.1.xml @@ -827,9 +827,10 @@ and suffix. -Available types are; base uses the base path of -the download, tied uses the path of the file the -download is tied to, see start_tied. +Available types are; base_path uses the base path +of the download, base_filename uses the base +filename of the download, tied uses the path of +the file the download is tied to, see start_tied. diff --git a/src/core/manager.cc b/src/core/manager.cc index 8e8a0a69..ccf332c2 100644 --- a/src/core/manager.cc +++ b/src/core/manager.cc @@ -494,7 +494,7 @@ Manager::receive_hashing_changed() { // something else when failed. for (View::iterator itr = m_hashingView->begin_visible(), last = m_hashingView->end_visible(); itr != last; ++itr) { if ((*itr)->is_hash_checked()) - throw torrent::internal_error("core::Manager::receive_hashing_changed() hash already checked or checking."); + throw torrent::internal_error("core::Manager::receive_hashing_changed() (*itr)->is_hash_checked()."); if ((*itr)->is_hash_checking()) { foundHashing = true; @@ -522,17 +522,21 @@ Manager::receive_hashing_changed() { // Need to clean up the below. if (tryQuick) { - if (!(*itr)->download()->hash_check(true)) - // Temporary hack. - (*itr)->download()->hash_stop(); + if ((*itr)->download()->hash_check(true)) + continue; // Make sure we don't repeat the quick hashing. - (*itr)->set_value("hashing", Download::variable_hashing_rehash); + (*itr)->download()->hash_stop(); - } else { - (*itr)->download()->hash_check(false); + if (foundHashing) { + (*itr)->set_value("hashing", Download::variable_hashing_rehash); + continue; + } } + (*itr)->download()->hash_check(false); + foundHashing = true; + } catch (torrent::local_error& e) { if (tryQuick) { // Make sure we don't repeat the quick hashing. diff --git a/src/option_handler_rules.cc b/src/option_handler_rules.cc index 8c61d931..4150d5f0 100644 --- a/src/option_handler_rules.cc +++ b/src/option_handler_rules.cc @@ -628,18 +628,22 @@ apply_d_create_link(core::Download* download, const std::string& args) { std::string target; std::string link; - if (type == "base") { + if (type == "base_path") { target = download->get_string("base_path"); link = rak::path_expand(prefix + download->get_string("base_path") + postfix); - } else if (type == "tied") { + } else if (type == "base_filename") { target = download->get_string("base_path"); + link = rak::path_expand(prefix + download->get_string("base_filename") + postfix); + + } else if (type == "tied") { link = rak::path_expand(download->get_string("tied_to_file")); if (link.empty()) return; link = rak::path_expand(prefix + link + postfix); + target = download->get_string("base_path"); } else { throw torrent::input_error("Unknown type argument."); @@ -647,7 +651,8 @@ apply_d_create_link(core::Download* download, const std::string& args) { if (symlink(target.c_str(), link.c_str()) == -1) // control->core()->push_log("create_link failed: " + std::string(rak::error_number::current().c_str())); - control->core()->push_log("create_link failed: " + std::string(rak::error_number::current().c_str()) + " to " + target); +// control->core()->push_log("create_link failed: " + std::string(rak::error_number::current().c_str()) + " to " + target); + ; // Disabled. } void @@ -663,9 +668,12 @@ apply_d_delete_link(core::Download* download, const std::string& args) { std::string link; - if (type == "base") { + if (type == "base_path") { link = rak::path_expand(prefix + download->get_string("base_path") + postfix); + } else if (type == "base_filename") { + link = rak::path_expand(prefix + download->get_string("base_filename") + postfix); + } else if (type == "tied") { link = rak::path_expand(download->get_string("tied_to_file")); @@ -694,6 +702,23 @@ retrieve_d_base_path(core::Download* download) { return download->file_list()->at(0)->frozen_path(); } +std::string +retrieve_d_base_filename(core::Download* download) { + std::string base; + + if (download->file_list()->is_multi_file()) + base = download->file_list()->root_dir(); + else + base = download->file_list()->at(0)->frozen_path(); + + std::string::size_type split = base.rfind('/'); + + if (split == std::string::npos) + return base; + else + return base.substr(split + 1); +} + void initialize_download_variables() { utils::VariableMap* variables = control->download_variables(); @@ -723,6 +748,7 @@ initialize_download_variables() { variables->insert("directory", new utils::VariableDownloadStringSlot(rak::ftor_fn1(rak::on(std::mem_fun(&core::Download::file_list), std::mem_fun(&torrent::FileList::root_dir))), rak::ftor_fn2(std::mem_fun(&core::Download::set_root_directory)))); variables->insert("base_path", new utils::VariableDownloadStringSlot(rak::ptr_fn(&retrieve_d_base_path), NULL)); + variables->insert("base_filename", new utils::VariableDownloadStringSlot(rak::ptr_fn(&retrieve_d_base_filename), NULL)); variables->insert("min_peers", var_d_value(&core::Download::download, &torrent::Download::peers_min, &torrent::Download::set_peers_min)); variables->insert("max_peers", var_d_value(&core::Download::download, &torrent::Download::peers_max, &torrent::Download::set_peers_max));