From 15ae43a5ea5a662d8de7b0a1ed626d4fdac44115 Mon Sep 17 00:00:00 2001 From: rakshasa Date: Tue, 18 Nov 2008 15:11:49 +0000 Subject: [PATCH] * Make 'seeding' view trigger filtering on 'event.download.finished'. * Fixed a potential buffer overflow in displaying of non-UTF8 filenames. * Changed torrent::DownloadList::close_directly() so doesn't save the session if the underlying file/directory has been moved or removed. This change, in addition to calling 'd.set_directory=' before 'execute=mv,...', as previously shown in the examples, will make rtorrent behave correctly when 'check_hash=no' is set. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1084 e378c898-3ddf-0310-93e7-cc216c733640 --- src/core/download_list.cc | 12 +++++++----- src/display/window_file_list.cc | 2 +- src/main.cc | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/core/download_list.cc b/src/core/download_list.cc index 2126c132..dff39f07 100644 --- a/src/core/download_list.cc +++ b/src/core/download_list.cc @@ -234,7 +234,9 @@ void DownloadList::close_directly(Download* download) { if (download->download()->is_active()) { download->download()->stop(torrent::Download::stop_skip_tracker); - torrent::resume_save_progress(*download->download(), download->download()->bencode()->get_key("libtorrent_resume")); + + if (torrent::resume_check_target_files(*download->download(), download->download()->bencode()->get_key("libtorrent_resume"))) + torrent::resume_save_progress(*download->download(), download->download()->bencode()->get_key("libtorrent_resume")); } if (download->download()->is_open()) @@ -519,14 +521,12 @@ void DownloadList::received_finished(Download* download) { check_contains(download); - if (rpc::call_command_value("get_check_hash")) { + if (rpc::call_command_value("get_check_hash")) // Set some 'checking_finished_thingie' variable to make hash_done // trigger correctly, also so it can bork on missing data. hash_queue(download, Download::variable_hashing_last); - - } else { + else confirm_finished(download); - } } // The download must be open when we call this function. @@ -547,6 +547,8 @@ DownloadList::confirm_finished(Download* download) { // Do this before the slots are called in case one of them closes // the download. + // + // Obsolete. if (!download->is_active() && rpc::call_command_value("get_session_on_completion") != 0) { torrent::resume_save_progress(*download->download(), download->download()->bencode()->get_key("libtorrent_resume")); control->core()->download_store()->save(download); diff --git a/src/display/window_file_list.cc b/src/display/window_file_list.cc index 6e8b30e2..be972763 100644 --- a/src/display/window_file_list.cc +++ b/src/display/window_file_list.cc @@ -68,7 +68,7 @@ wstring_width(const std::string& i_str, int width) { if (length == (size_t)-1) { wchar_t* out = result; - for (std::string::const_iterator itr = i_str.begin(); itr != i_str.end(); ++itr) + for (std::string::const_iterator itr = i_str.begin(); out != result + width && itr != i_str.end(); ++itr) if (!std::isprint(*itr, std::locale::classic())) *out++ = '?'; else diff --git a/src/main.cc b/src/main.cc index 246a4a8a..f6304a51 100644 --- a/src/main.cc +++ b/src/main.cc @@ -268,7 +268,7 @@ main(int argc, char** argv) { "view_add = seeding\n" "view_filter = seeding,\"and=d.get_state=,d.get_complete=\"\n" - "view_filter_on = seeding,event.download.resumed,event.download.paused\n" + "view_filter_on = seeding,event.download.resumed,event.download.paused,event.download.finished\n" "view_sort_new = seeding,less=d.get_state_changed=\n" "view_sort_current = seeding,less=d.get_state_changed=\n"