diff --git a/src/command_download.cc b/src/command_download.cc index cb208307..36aee870 100644 --- a/src/command_download.cc +++ b/src/command_download.cc @@ -718,7 +718,7 @@ initialize_command_download() { CMD2_DL_V ("d.pause", std::bind(&core::DownloadList::pause_default, control->core()->download_list(), std::placeholders::_1)); CMD2_DL_V ("d.open", std::bind(&core::DownloadList::open_throw, control->core()->download_list(), std::placeholders::_1)); CMD2_DL_V ("d.close", std::bind(&core::DownloadList::close_throw, control->core()->download_list(), std::placeholders::_1)); - CMD2_DL_V ("d.close.directly", std::bind(&core::DownloadList::close_directly, control->core()->download_list(), std::placeholders::_1)); + CMD2_DL_V ("d.close.directly", std::bind(&core::DownloadList::close_files, control->core()->download_list(), std::placeholders::_1)); CMD2_DL_V ("d.erase", std::bind(&core::DownloadList::erase_ptr, control->core()->download_list(), std::placeholders::_1)); CMD2_DL_V ("d.check_hash", std::bind(&core::DownloadList::check_hash, control->core()->download_list(), std::placeholders::_1)); diff --git a/src/core/download.cc b/src/core/download.cc index c28badc8..4dabdc70 100644 --- a/src/core/download.cc +++ b/src/core/download.cc @@ -126,7 +126,7 @@ Download::set_root_directory(const std::string& path) { throw torrent::input_error("Cannot change the directory of an open download after the files have been moved."); } - control->core()->download_list()->close_directly(this); + control->core()->download_list()->close_files(this); file_list->set_root_dir(expand_path(path)); bencode()->get_key("rtorrent").insert_key("directory", path); diff --git a/src/core/download_list.cc b/src/core/download_list.cc index a0acb4b2..3a4b3214 100644 --- a/src/core/download_list.cc +++ b/src/core/download_list.cc @@ -254,9 +254,11 @@ DownloadList::close(Download* download) { } } +// Releases the files without changing the download's state, for callers that +// need the files closed and will keep using the download. void -DownloadList::close_directly(Download* download) { - lt_log_print_info(torrent::LOG_TORRENT_INFO, download->info(), "download_list", "Closing download directly."); +DownloadList::close_files(Download* download) { + lt_log_print_info(torrent::LOG_TORRENT_INFO, download->info(), "download_list", "Closing download files."); if (download->download()->info()->is_active()) { download->download()->stop(torrent::Download::stop_skip_tracker); @@ -269,6 +271,13 @@ DownloadList::close_directly(Download* download) { download->download()->close(); } +void +DownloadList::close_directly(Download* download) { + lt_log_print_info(torrent::LOG_TORRENT_INFO, download->info(), "download_list", "Closing download directly."); + + close_files(download); +} + void DownloadList::close_quick(Download* download) { lt_log_print_info(torrent::LOG_TORRENT_INFO, download->info(), "download_list", "Closing download quickly."); diff --git a/src/core/download_list.h b/src/core/download_list.h index e860876c..f3fe5b5f 100644 --- a/src/core/download_list.h +++ b/src/core/download_list.h @@ -75,6 +75,7 @@ public: void close(Download* d); void close_directly(Download* d); + void close_files(Download* d); void close_quick(Download* d); void close_throw(Download* d);