mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-15 11:51:33 +00:00
Probe config-supplied paths without throwing on an unreadable path (#15669)
The startup probes for download_path and last_backup_path used the throwing boost::filesystem overloads, so a path that could not be probed at all, such as one whose parent is not searchable, raised filesystem_error instead of falling back. init_download_path() runs from the GUI_App constructor inside GUI_Run()'s try, which left the application showing a message box and exiting with no window and no log file, the throw preceding the log sink. has_restore_data() runs from the queued EVT_RESTORE_PROJECT handler, whose try starts after the call. Five probes in those three functions take the error_code overload instead. Nothing branches on ec, and readable or missing paths are unaffected because both overloads return the same value for them. A new test covers has_restore_data() against a backup directory whose parent has no search permission, and skips on Windows, as root, and where the mode change is refused or not enforced.
This commit is contained in:
@@ -2606,7 +2606,10 @@ void GUI_App::init_download_path()
|
||||
}
|
||||
else {
|
||||
fs::path dp(down_path);
|
||||
if (!fs::exists(dp)) {
|
||||
// ORCA: non-throwing probe; ec is deliberately unread, a download_path that cannot be
|
||||
// probed falls back to the default like a missing one instead of failing startup.
|
||||
boost::system::error_code ec;
|
||||
if (!fs::exists(dp, ec)) {
|
||||
|
||||
std::string user_down_path = wxStandardPaths::Get().GetUserDir(wxStandardPaths::Dir_Downloads).ToUTF8().data();
|
||||
app_config->set("download_path", user_down_path);
|
||||
@@ -10132,7 +10135,9 @@ void GUI_App::start_download(std::string url)
|
||||
}
|
||||
//lets always init so if the download dest folder was changed, new dest is used
|
||||
boost::filesystem::path dest_folder(app_config->get("download_path"));
|
||||
if (dest_folder.empty() || !boost::filesystem::is_directory(dest_folder)) {
|
||||
// ORCA: non-throwing probe, as in init_download_path(); ec is deliberately unread.
|
||||
boost::system::error_code ec;
|
||||
if (dest_folder.empty() || !boost::filesystem::is_directory(dest_folder, ec)) {
|
||||
std::string msg = _u8L("Could not start URL download. Destination folder is not set. Please choose destination folder in Configuration Wizard.");
|
||||
BOOST_LOG_TRIVIAL(error) << msg;
|
||||
show_error(nullptr, msg);
|
||||
|
||||
Reference in New Issue
Block a user