From 9dd54038b41e9e18b78564c211bb7e173aa7c079 Mon Sep 17 00:00:00 2001 From: Ivan Date: Mon, 19 Oct 2026 19:07:36 +0300 Subject: [PATCH] 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. --- src/core/download_factory.cc | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/core/download_factory.cc b/src/core/download_factory.cc index bb5c512f..9f3630e8 100644 --- a/src/core/download_factory.cc +++ b/src/core/download_factory.cc @@ -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));