mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-09 19:52:31 +00:00
* Fixed a bug that cause the hash checker not to start.
* Added "base_path" and "base_filename" types to the "create/delete_link" command. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@851 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user