Split the file closing in DownloadList::close_directly() into close_files().

Callers that only need the files released should not depend on how a stop behaves.
This commit is contained in:
noctuum
2026-08-28 06:28:35 +05:00
committed by Jari Sundell
parent 072cbae0c6
commit 60eb8f0383
4 changed files with 14 additions and 4 deletions
+1 -1
View File
@@ -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));
+1 -1
View File
@@ -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);
+11 -2
View File
@@ -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.");
+1
View File
@@ -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);