From 5cee2208d70ade1f497679f7fb6cca88ec731eeb Mon Sep 17 00:00:00 2001 From: "lane.wei" Date: Fri, 14 Oct 2022 09:53:49 +0800 Subject: [PATCH] ENH: do not throw exception when data directory creating failed in some cases if the directory already created by other instance do not throw exception Change-Id: I3ebde1ab62fa85ea946b6aeafc87aa7468327ce6 --- src/libslic3r/PresetBundle.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/libslic3r/PresetBundle.cpp b/src/libslic3r/PresetBundle.cpp index 6a731dfda..d35456c98 100644 --- a/src/libslic3r/PresetBundle.cpp +++ b/src/libslic3r/PresetBundle.cpp @@ -179,8 +179,13 @@ void PresetBundle::setup_directories() boost::filesystem::path subdir = path; subdir.make_preferred(); if (! boost::filesystem::is_directory(subdir) && - ! boost::filesystem::create_directory(subdir)) - throw Slic3r::RuntimeError(std::string("Unable to create directory ") + subdir.string()); + ! boost::filesystem::create_directory(subdir)) { + if (boost::filesystem::is_directory(subdir)) { + BOOST_LOG_TRIVIAL(warning) << boost::format("creating directory %1% failed, maybe created by other instance, go on!")%subdir.string(); + } + else + throw Slic3r::RuntimeError(std::string("Unable to create directory ") + subdir.string()); + } } } @@ -659,7 +664,7 @@ PresetsConfigSubstitutions PresetBundle::import_presets(std::vector continue; } new_config.apply(std::move(config)); - + Preset &preset = collection->load_preset(collection->path_from_name(name), name, std::move(new_config), false); preset.is_external = true; preset.version = *version; @@ -838,7 +843,7 @@ void PresetBundle::remove_users_preset(AppConfig& config) } else { printers.select_preset_by_name(printer_selected_preset_name, false); } - + std::string selected_print_name = prints.get_selected_preset().name; bool need_reset_print_preset = false; // remove preset if user_id is not current user