From 92b72953030b3e485bcdf270e77dec1d31315445 Mon Sep 17 00:00:00 2001 From: Jari Sundell Date: Mon, 3 Oct 2011 13:20:33 +0900 Subject: [PATCH 1/3] Removing unneeded TODO file. --- TODO | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 TODO diff --git a/TODO b/TODO deleted file mode 100644 index ac8c2c48..00000000 --- a/TODO +++ /dev/null @@ -1,19 +0,0 @@ -See libtorrent/TODO for a list of TODO items. - -Polling during last phase of shutdown should be very quick, don't use -normal timeout. - -Consider basing WindowPeer* on a common base class. - -Some kind of indication that a tracker request was tried, but won't be -allowed since the tracker set a min interval. - -Make accumulate return the value, no refs please... - -> - seeing the number of seeds / leechers of a torrent on the main -> screen (and the level of distribution between leechers); - -> - being able to delete not just the torrent file, but the files it -> created from rtorrent. Like when you start a torrent, but it is too -> slow or broken or for various reasons you don't want to download it. - From aaa55860885e7eb46a9d804a50643bdc33d0097e Mon Sep 17 00:00:00 2001 From: Jari Sundell Date: Mon, 3 Oct 2011 20:25:02 +0900 Subject: [PATCH 2/3] Added '__builtin_popcount' check to 'configure.ac' as 'rak/algorithms.h' needs it. --- configure.ac | 1 + 1 file changed, 1 insertion(+) diff --git a/configure.ac b/configure.ac index 94dc56b0..5bac9e06 100644 --- a/configure.ac +++ b/configure.ac @@ -48,6 +48,7 @@ AC_DEFINE(USER_AGENT, [std::string(PACKAGE "/" VERSION "/") + torrent::version() AC_CHECK_FUNCS(posix_memalign) TORRENT_CHECK_CACHELINE() +TORRENT_CHECK_POPCOUNT() CC_ATTRIBUTE_UNUSED( AC_DEFINE([__UNUSED], [__attribute__((unused))], [Wrapper around unused attribute]), From fa5224bf7f50ca93f3698c7f2bc7e634d7dccd40 Mon Sep 17 00:00:00 2001 From: Jari Sundell Date: Tue, 4 Oct 2011 22:52:35 +0900 Subject: [PATCH 3/3] Moved the sanity checks for 'd.directory.set' to 'Download::set_root_directory(path)' so that it always gets used. --- src/command_download.cc | 23 ----------------------- src/core/download.cc | 28 +++++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/src/command_download.cc b/src/command_download.cc index d203cf22..93a916a3 100644 --- a/src/command_download.cc +++ b/src/command_download.cc @@ -175,29 +175,6 @@ apply_d_delete_tied(core::Download* download) { void apply_d_directory(core::Download* download, const std::string& name) { - // If the download is open, hashed and has completed chunks make - // sure to verify that the download files are still present. - // - // This should ensure that no one tries to set the destination - // directory 'after' moving files. In cases where the user wants to - // override this behavior the download must first be closed or - // 'd.directory_base.set' may be used. - rak::file_stat file_stat; - torrent::FileList* file_list = download->file_list(); - - if (download->is_hash_checked() && file_list->completed_chunks() != 0 && - - (file_list->is_multi_file() ? - !file_list->is_root_dir_created() : - !file_stat.update(file_list->front()->frozen_path()))) { - - download->set_message("Cannot change the directory of an open download after the files have been moved."); - rpc::call_command("d.state.set", (int64_t)0, rpc::make_target(download)); - control->core()->download_list()->close_directly(download); - - throw torrent::input_error("Cannot change the directory of an open download atter the files have been moved."); - } - if (!download->file_list()->is_multi_file()) download->set_root_directory(name); else if (name.empty() || *name.rbegin() == '/') diff --git a/src/core/download.cc b/src/core/download.cc index bebdaaad..eb1240f4 100644 --- a/src/core/download.cc +++ b/src/core/download.cc @@ -39,8 +39,9 @@ #include #include #include -#include +#include #include +#include #include #include #include @@ -172,10 +173,31 @@ Download::set_throttle_name(const std::string& throttleName) { void Download::set_root_directory(const std::string& path) { - torrent::FileList* fileList = m_download.file_list(); + // If the download is open, hashed and has completed chunks make + // sure to verify that the download files are still present. + // + // This should ensure that no one tries to set the destination + // directory 'after' moving files. In cases where the user wants to + // override this behavior the download must first be closed or + // 'd.directory_base.set' may be used. + rak::file_stat file_stat; + torrent::FileList* file_list = m_download.file_list(); + + if (is_hash_checked() && file_list->completed_chunks() != 0 && + + (file_list->is_multi_file() ? + !file_list->is_root_dir_created() : + !file_stat.update(file_list->front()->frozen_path()))) { + + set_message("Cannot change the directory of an open download after the files have been moved."); + rpc::call_command("d.state.set", (int64_t)0, rpc::make_target(this)); + control->core()->download_list()->close_directly(this); + + throw torrent::input_error("Cannot change the directory of an open download atter the files have been moved."); + } control->core()->download_list()->close_directly(this); - fileList->set_root_dir(rak::path_expand(path)); + file_list->set_root_dir(rak::path_expand(path)); bencode()->get_key("rtorrent").insert_key("directory", path); }