From e76ca8febf72a0c6cbdd16003171e176c94048b1 Mon Sep 17 00:00:00 2001 From: SoftFever Date: Sun, 17 Mar 2024 11:22:52 +0800 Subject: [PATCH] Minor tweak: avoid exceptions --- resources/printers/N1.json | 1 + resources/printers/N2S.json | 1 + src/slic3r/Utils/PresetUpdater.cpp | 23 ++++++++++++++++------- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/resources/printers/N1.json b/resources/printers/N1.json index 8bcd035a5e..85da862315 100644 --- a/resources/printers/N1.json +++ b/resources/printers/N1.json @@ -28,6 +28,7 @@ "support_print_all":false, "support_print_without_sd":false, "support_flow_calibration":true, + "support_build_plate_marker_detect":false, "support_lidar_calibration":false, "support_ai_monitoring":false, "support_first_layer_inspect":false, diff --git a/resources/printers/N2S.json b/resources/printers/N2S.json index 2857bb17eb..e287cd1fab 100644 --- a/resources/printers/N2S.json +++ b/resources/printers/N2S.json @@ -28,6 +28,7 @@ "support_print_all":false, "support_print_without_sd":false, "support_flow_calibration":true, + "support_build_plate_marker_detect":false, "support_lidar_calibration":false, "support_ai_monitoring":false, "support_first_layer_inspect":false, diff --git a/src/slic3r/Utils/PresetUpdater.cpp b/src/slic3r/Utils/PresetUpdater.cpp index 483a10fc7b..bb61978471 100644 --- a/src/slic3r/Utils/PresetUpdater.cpp +++ b/src/slic3r/Utils/PresetUpdater.cpp @@ -942,12 +942,18 @@ void PresetUpdater::priv::sync_printer_config(std::string http_url) auto cache_folder = data_dir_path / "ota" / "printers"; try { - Slic3r::load_string_file(config_folder / "version.txt", curr_version); - boost::algorithm::trim(curr_version); + auto version_file = config_folder / "version.txt"; + if (fs::exists(version_file)) { + Slic3r::load_string_file(version_file, curr_version); + boost::algorithm::trim(curr_version); + } } catch (...) {} try { - Slic3r::load_string_file(cache_folder / "version.txt", cached_version); - boost::algorithm::trim(cached_version); + auto version_file = cache_folder / "version.txt"; + if (fs::exists(version_file)) { + Slic3r::load_string_file(version_file, cached_version); + boost::algorithm::trim(cached_version); + } } catch (...) {} if (!cached_version.empty()) { bool need_delete_cache = false; @@ -980,9 +986,12 @@ void PresetUpdater::priv::sync_printer_config(std::string http_url) bool result = false; try { - Slic3r::load_string_file(cache_folder / "version.txt", cached_version); - boost::algorithm::trim(cached_version); - result = true; + auto version_file = cache_folder / "version.txt"; + if (fs::exists(version_file)) { + Slic3r::load_string_file(version_file, cached_version); + boost::algorithm::trim(cached_version); + result = true; + } } catch (...) {} if (result) { BOOST_LOG_TRIVIAL(info) << format("[Orca Updater] found new printer config: %1%, prompt to update", cached_version);