From ef90f0f51e3a5fec57d8576261184a0d4fb2e54e Mon Sep 17 00:00:00 2001 From: rakshasa Date: Sat, 22 Jul 2006 20:41:47 +0000 Subject: [PATCH] * Added resume functions for saving/loading tracker state. * Added parameter to torrent::resume_save_progress to indicate that only completed files are to be saved. This is used when the torrent is active. * Update the display when priority is changed. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@746 e378c898-3ddf-0310-93e7-cc216c733640 --- src/core/download_factory.cc | 1 + src/core/download_list.cc | 2 +- src/core/download_store.cc | 7 +++++-- src/display/manager.cc | 11 +++++------ src/ui/download_list.cc | 2 ++ 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/core/download_factory.cc b/src/core/download_factory.cc index b1a640b9..64278614 100644 --- a/src/core/download_factory.cc +++ b/src/core/download_factory.cc @@ -193,6 +193,7 @@ DownloadFactory::receive_success() { torrent::resume_load_addresses(*download->download(), resumeObject); torrent::resume_load_file_priorities(*download->download(), resumeObject); + torrent::resume_load_tracker_settings(*download->download(), resumeObject); // The action of inserting might cause the torrent to be // opened/started or such. Figure out a nicer way of handling this. diff --git a/src/core/download_list.cc b/src/core/download_list.cc index 137eb2c8..cf944561 100644 --- a/src/core/download_list.cc +++ b/src/core/download_list.cc @@ -321,7 +321,7 @@ DownloadList::resume(Download* download) { // on non-complete downloads after a crash. This shouldn't be // needed, but for some reason linux 2.6 is very lazy about // updating mtime. - torrent::resume_clear_progress(*download->download(), download->download()->bencode()->get_key("libtorrent_resume")); + torrent::resume_save_progress(*download->download(), download->download()->bencode()->get_key("libtorrent_resume"), true); } // Update the priority to ensure it has the correct diff --git a/src/core/download_store.cc b/src/core/download_store.cc index 04418eff..23b1ebb1 100644 --- a/src/core/download_store.cc +++ b/src/core/download_store.cc @@ -109,8 +109,11 @@ DownloadStore::save(Download* d) { 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()); - torrent::resume_save_addresses(*d->download(), d->download()->bencode()->get_key("libtorrent_resume")); - torrent::resume_save_file_priorities(*d->download(), d->download()->bencode()->get_key("libtorrent_resume")); + torrent::Object& resumeObject = d->download()->bencode()->get_key("libtorrent_resume"); + + torrent::resume_save_addresses(*d->download(), resumeObject); + torrent::resume_save_file_priorities(*d->download(), resumeObject); + torrent::resume_save_tracker_settings(*d->download(), resumeObject); f << *d->bencode(); diff --git a/src/display/manager.cc b/src/display/manager.cc index 89fc38c3..256073c5 100644 --- a/src/display/manager.cc +++ b/src/display/manager.cc @@ -107,11 +107,11 @@ Manager::unschedule(Window* w) { void Manager::adjust_layout() { int staticHeight = std::for_each(begin(), end(), - rak::if_then(std::mem_fun(&Window::is_active), - rak::accumulate(0, std::mem_fun(&Window::get_min_height)))).m_then.result; + rak::if_then(std::mem_fun(&Window::is_active), + rak::accumulate(0, std::mem_fun(&Window::get_min_height)))).m_then.result; int countDynamic = std::for_each(begin(), end(), - rak::if_then(std::mem_fun(&Window::is_active), - rak::accumulate(0, std::mem_fun(&Window::is_dynamic)))).m_then.result; + rak::if_then(std::mem_fun(&Window::is_active), + rak::accumulate(0, std::mem_fun(&Window::is_dynamic)))).m_then.result; int dynamic = std::max(0, Canvas::get_screen_height() - staticHeight); int height = 0, h; @@ -166,8 +166,7 @@ Manager::schedule_update() { if (!m_taskUpdate.is_queued() || m_taskUpdate.time() > m_scheduler.top()->time()) { rak::priority_queue_erase(&taskScheduler, &m_taskUpdate); - rak::priority_queue_insert(&taskScheduler, &m_taskUpdate, - std::max(m_scheduler.top()->time(), m_timeLastUpdate + 50000)); + rak::priority_queue_insert(&taskScheduler, &m_taskUpdate, std::max(m_scheduler.top()->time(), m_timeLastUpdate + 50000)); } } diff --git a/src/ui/download_list.cc b/src/ui/download_list.cc index 598e4faf..c9590875 100644 --- a/src/ui/download_list.cc +++ b/src/ui/download_list.cc @@ -264,6 +264,7 @@ DownloadList::receive_next_priority() { return; (*m_view->focus())->set_priority(((*m_view->focus())->priority() + 1) % 4); + (*m_window)->mark_dirty(); } void @@ -272,6 +273,7 @@ DownloadList::receive_prev_priority() { return; (*m_view->focus())->set_priority(((*m_view->focus())->priority() - 1) % 4); + (*m_window)->mark_dirty(); } void