From 9f2f427e9da8300f030be6651b8ad9d451cffce0 Mon Sep 17 00:00:00 2001 From: rakshasa Date: Fri, 30 Jun 2006 01:02:41 +0000 Subject: [PATCH] * Fixed the transitions between skipping and downloading pieces. * Added Object::merge_recursive. * Save and set the chunks done count for closed torrents. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@733 e378c898-3ddf-0310-93e7-cc216c733640 --- src/core/download.cc | 17 ++++++----------- src/core/download_factory.cc | 3 +++ src/core/download_store.cc | 3 ++- src/display/utils.cc | 10 ++++++---- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/core/download.cc b/src/core/download.cc index 33d380ba..4e3f40de 100644 --- a/src/core/download.cc +++ b/src/core/download.cc @@ -68,7 +68,7 @@ Download::Download(download_type d) : m_download.signal_chunk_failed(sigc::mem_fun(*this, &Download::receive_chunk_failed)); m_variables.insert("connection_current", new utils::VariableStringSlot(rak::mem_fn(this, &Download::connection_current), - rak::mem_fn(this, &Download::set_connection_current))); + rak::mem_fn(this, &Download::set_connection_current))); m_variables.insert("connection_leech", new utils::VariableAny(connection_type_to_string(download_type::CONNECTION_LEECH))); m_variables.insert("connection_seed", new utils::VariableAny(connection_type_to_string(download_type::CONNECTION_SEED))); @@ -89,17 +89,12 @@ Download::Download(download_type d) : // resume/pause. m_variables.insert("state_changed", new utils::VariableObject(bencode(), "rtorrent", "state_changed", torrent::Object::TYPE_VALUE)); - m_variables.insert("directory", new utils::VariableStringSlot(rak::mem_fn(&m_fileList, &torrent::FileList::root_dir), - rak::mem_fn(this, &Download::set_root_directory))); + m_variables.insert("directory", new utils::VariableStringSlot(rak::mem_fn(&m_fileList, &torrent::FileList::root_dir), rak::mem_fn(this, &Download::set_root_directory))); - m_variables.insert("min_peers", new utils::VariableValueSlot(rak::mem_fn(&m_download, &download_type::peers_min), - rak::mem_fn(&m_download, &download_type::set_peers_min))); - m_variables.insert("max_peers", new utils::VariableValueSlot(rak::mem_fn(&m_download, &download_type::peers_max), - rak::mem_fn(&m_download, &download_type::set_peers_max))); - m_variables.insert("max_uploads", new utils::VariableValueSlot(rak::mem_fn(&m_download, &download_type::uploads_max), - rak::mem_fn(&m_download, &download_type::set_uploads_max))); - m_variables.insert("priority", new utils::VariableValueSlot(rak::mem_fn(this, &Download::priority), - rak::mem_fn(this, &Download::set_priority))); + m_variables.insert("min_peers", new utils::VariableValueSlot(rak::mem_fn(&m_download, &download_type::peers_min), rak::mem_fn(&m_download, &download_type::set_peers_min))); + m_variables.insert("max_peers", new utils::VariableValueSlot(rak::mem_fn(&m_download, &download_type::peers_max), rak::mem_fn(&m_download, &download_type::set_peers_max))); + m_variables.insert("max_uploads", new utils::VariableValueSlot(rak::mem_fn(&m_download, &download_type::uploads_max), rak::mem_fn(&m_download, &download_type::set_uploads_max))); + m_variables.insert("priority", new utils::VariableValueSlot(rak::mem_fn(this, &Download::priority), rak::mem_fn(this, &Download::set_priority))); m_variables.insert("ignore_ratio", new utils::VariableObject(bencode(), "rtorrent", "ignore_ratio", torrent::Object::TYPE_VALUE)); } diff --git a/src/core/download_factory.cc b/src/core/download_factory.cc index f1476eac..ee07929a 100644 --- a/src/core/download_factory.cc +++ b/src/core/download_factory.cc @@ -266,6 +266,9 @@ DownloadFactory::initialize_rtorrent(Download* download, torrent::Object* rtorre if (rtorrent->has_key_value("total_uploaded")) download->download()->up_rate()->set_total(rtorrent->get_key_value("total_uploaded")); + if (rtorrent->has_key_value("chunks_done")) + download->download()->set_chunks_done(std::min(rtorrent->get_key_value("chunks_done"), download->download()->chunks_total())); + if (!rtorrent->has_key_value("ignore_ratio")) rtorrent->insert_key("ignore_ratio", (int64_t)0); } diff --git a/src/core/download_store.cc b/src/core/download_store.cc index 904d85ea..f64d6a68 100644 --- a/src/core/download_store.cc +++ b/src/core/download_store.cc @@ -104,8 +104,9 @@ DownloadStore::save(Download* d) { if (!f.is_open()) return; - // Move this somewhere else. + // Move this somewhere else? d->bencode()->get_key("rtorrent").insert_key("total_uploaded", d->download()->up_rate()->total()); + d->bencode()->get_key("rtorrent").insert_key("chunks_done", d->download()->chunks_done()); f << *d->bencode(); diff --git a/src/display/utils.cc b/src/display/utils.cc index f6c9587b..536065fa 100644 --- a/src/display/utils.cc +++ b/src/display/utils.cc @@ -123,12 +123,14 @@ print_download_title(char* first, char* last, core::Download* d) { char* print_download_info(char* first, char* last, core::Download* d) { - first = print_buffer(first, last, "Torrent: "); - if (!d->download()->is_open()) - first = print_buffer(first, last, "closed "); + first = print_buffer(first, last, "[CLOSED] "); + else if (!d->download()->is_active()) + first = print_buffer(first, last, "[OPEN] "); + else + first = print_buffer(first, last, " "); - else if (d->is_done()) + if (d->is_done()) first = print_buffer(first, last, "done %10.1f MB", (double)d->download()->bytes_total() / (double)(1 << 20)); else first = print_buffer(first, last, "%6.1f / %6.1f MB",