diff --git a/src/slic3r/Utils/PresetUpdater.cpp b/src/slic3r/Utils/PresetUpdater.cpp index c4900190f9..6a2f45b827 100644 --- a/src/slic3r/Utils/PresetUpdater.cpp +++ b/src/slic3r/Utils/PresetUpdater.cpp @@ -208,6 +208,8 @@ struct PresetUpdater::priv // Per-vendor update checking std::set checked_vendors; + std::unordered_map vendor_changelogs; + mutable std::mutex vendor_changelogs_mutex; std::mutex vendor_check_mutex; std::vector vendor_check_threads; std::atomic vendor_check_cancel{false}; @@ -675,6 +677,9 @@ void PresetUpdater::priv::sync_vendor_config(const std::string& vendor_id) std::string online_version_str; // this represents the PROFILE VERSION, not ORCA VERSION std::string download_url_str; + std::string changelog; + + BOOST_LOG_TRIVIAL(info) << "[Orca Updater] fetching vendor update status from " << url; Http::get(url) .timeout_connect(5) @@ -687,9 +692,13 @@ void PresetUpdater::priv::sync_vendor_config(const std::string& vendor_id) if (http_status != 200) return; try { json j = json::parse(body); - if (j.contains("vendor_version") && j.contains("download_url")) { - online_version_str = j["vendor_version"].get(); + BOOST_LOG_TRIVIAL(info) << "[Orca Updater] url: " << url << " returned:" << body; + + if ((j.contains("version") || j.contains("vendor_version")) && j.contains("download_url")) { + online_version_str = j.contains("version") ? j["version"].get() + : j["vendor_version"].get(); download_url_str = j["download_url"].get(); + changelog = j.value("changelog", std::string()); } } catch (const std::exception& e) { BOOST_LOG_TRIVIAL(warning) << "[Orca Updater] vendor check JSON parse failed: " << e.what(); @@ -711,7 +720,6 @@ void PresetUpdater::priv::sync_vendor_config(const std::string& vendor_id) boost::system::error_code ec; fs::remove_all(cache_profile_path / vendor_id, ec); fs::remove(cache_profile_path / (vendor_id + ".json"), ec); - fs::remove(cache_profile_path / (vendor_id + ".changelog"), ec); // Download the zip BOOST_LOG_TRIVIAL(info) << "[Orca Updater] downloading update for " << vendor_id @@ -749,6 +757,11 @@ void PresetUpdater::priv::sync_vendor_config(const std::string& vendor_id) if (cancel || vendor_check_cancel) return; + { + std::lock_guard lock(vendor_changelogs_mutex); + vendor_changelogs[vendor_id] = std::move(changelog); + } + BOOST_LOG_TRIVIAL(info) << "[Orca Updater] vendor " << vendor_id << " update cached, notifying UI"; GUI::wxGetApp().CallAfter([] { GUI::wxGetApp().check_config_updates_from_updater(); @@ -1190,6 +1203,12 @@ Updates PresetUpdater::priv::get_config_updates(const Semver &old_slic3r_version if (!fs::exists(cache_profile_path)) return updates; + std::unordered_map changelogs; + { + std::lock_guard lock(vendor_changelogs_mutex); + changelogs = vendor_changelogs; + } + for (auto &dir_entry : boost::filesystem::directory_iterator(cache_profile_path)) { const auto &path = dir_entry.path(); std::string file_path = path.string(); @@ -1223,15 +1242,8 @@ Updates PresetUpdater::priv::get_config_updates(const Semver &old_slic3r_version if (config_version) cache_ver = *config_version; - std::string changelog; - std::string changelog_file = (cache_profile_path / (vendor_name + ".changelog")).string(); - boost::nowide::ifstream ifs(changelog_file); - if (ifs) { - std::ostringstream oss; - oss<< ifs.rdbuf(); - changelog = oss.str(); - ifs.close(); - } + const auto changelog_it = changelogs.find(vendor_name); + std::string changelog = changelog_it != changelogs.end() ? changelog_it->second : std::string(); if (vendor_ver < cache_ver) { BOOST_LOG_TRIVIAL(info) << "[Orca Updater]:need to update settings from " << vendor_ver.to_string()