Abort loading a torrent when file_split_all() fails

A zero split size, or a file needing over 1000 parts, made the next load exit rtorrent.
This commit is contained in:
Ivan
2026-10-19 19:07:36 +03:00
committed by Jari Sundell
parent 8df6f23e77
commit 9dd54038b4
+15 -6
View File
@@ -278,12 +278,21 @@ DownloadFactory::receive_success() {
// Check first if we already have these values set in the session
// torrent, so that it is safe to change the values.
//
// Need to also catch the exceptions.
if (rpc::call_command_value("system.file.split_size") >= 0)
torrent::file_split_all(download->download()->file_list(),
rpc::call_command_value("system.file.split_size"),
rpc::call_command_string("system.file.split_suffix"));
try {
if (rpc::call_command_value("system.file.split_size") >= 0)
torrent::file_split_all(download->download()->file_list(),
rpc::call_command_value("system.file.split_size"),
rpc::call_command_string("system.file.split_suffix"));
} catch (const torrent::input_error& e) {
std::string msg = "Could not split files: " + std::string(e.what());
lt_log_print(torrent::LOG_ERRORS, "%s: %s", msg.c_str(), m_uri.c_str());
torrent::download_remove(*download->download());
delete download;
return receive_failed(msg);
}
if (rtorrent->has_key_string("directory")) {
rpc::call_command("d.directory_base.set", rtorrent->get_key("directory"), rpc::make_target(download));