From 54ed1cbadec16aa43d12b5eaf82308c0c3246629 Mon Sep 17 00:00:00 2001 From: Hanif Koh Date: Mon, 28 Sep 2026 16:38:14 +0800 Subject: [PATCH] Handle Filesystem Errors When Finishing a Model Import Download Choosing the final name and moving the downloaded project into place could throw from inside the download callback. Any such error now removes the temporary file and reports the existing import failure message. --- src/slic3r/GUI/Plater.cpp | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 59b587bc07..ec6c35160e 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -15812,19 +15812,22 @@ void Plater::import_model_id(wxString download_info) fs::fstream file(tmp_path, std::ios::out | std::ios::binary | std::ios::trunc); file.write(body.c_str(), body.size()); file.close(); - // Another file may have taken the name while downloading. - std::string unused_filename; - if (!find_unused_filename(target_path.parent_path(), target_path.filename().string(), {}, unused_filename)) { - boost::system::error_code ec; - fs::remove(tmp_path, ec); - msg = _L("Importing to Orca Slicer failed. Please download the file and manually import it."); - cont = false; - return; - } - target_path = target_path.parent_path() / unused_filename; - fs::rename(tmp_path, target_path); cont = false; - download_ok = true; + try { + // Another file may have taken the name while downloading. + std::string unused_filename; + if (find_unused_filename(target_path.parent_path(), target_path.filename().string(), {}, unused_filename)) { + target_path = target_path.parent_path() / unused_filename; + fs::rename(tmp_path, target_path); + download_ok = true; + return; + } + } catch (const std::exception &e) { + BOOST_LOG_TRIVIAL(error) << "import_model_id: failed to move the download into place: " << e.what(); + } + boost::system::error_code ec; + fs::remove(tmp_path, ec); + msg = _L("Importing to Orca Slicer failed. Please download the file and manually import it."); }).perform_sync(); // for break while