mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-10 20:22: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:
+4
-3
@@ -827,9 +827,10 @@ and <emphasis>suffix</emphasis>.
|
||||
|
||||
</para><para>
|
||||
|
||||
Available types are; <emphasis>base</emphasis> uses the base path of
|
||||
the download, <emphasis>tied</emphasis> uses the path of the file the
|
||||
download is tied to, see <emphasis>start_tied</emphasis>.
|
||||
Available types are; <emphasis>base_path</emphasis> uses the base path
|
||||
of the download, <emphasis>base_filename</emphasis> uses the base
|
||||
filename of the download, <emphasis>tied</emphasis> uses the path of
|
||||
the file the download is tied to, see <emphasis>start_tied</emphasis>.
|
||||
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
+11
-7
@@ -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.
|
||||
|
||||
@@ -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