From 7595775ba50f5d27315cbf16aca9071b3ed80dec Mon Sep 17 00:00:00 2001 From: "lane.wei" Date: Tue, 28 Mar 2023 21:52:23 +0800 Subject: [PATCH] ENH: update: remove the old cached ota files in some corner case Change-Id: I8039e21045d33827dae096b18feead6150981056 (cherry picked from commit d920b3a57c284422e09c952b103c5f26ae551d2a) --- src/slic3r/Utils/PresetUpdater.cpp | 75 +++++++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 2 deletions(-) diff --git a/src/slic3r/Utils/PresetUpdater.cpp b/src/slic3r/Utils/PresetUpdater.cpp index de3a8b292d..eed76224a6 100644 --- a/src/slic3r/Utils/PresetUpdater.cpp +++ b/src/slic3r/Utils/PresetUpdater.cpp @@ -914,8 +914,79 @@ void PresetUpdater::priv::sync_plugins(std::string http_url, std::string plugin_ std::string cached_version; get_cached_plugins_version(cached_version); - if (!cached_version.empty()) - plugin_version = cached_version; + if (!cached_version.empty()) { + bool need_delete_cache = false; + Semver current_semver = curr_version; + Semver cached_semver = cached_version; + + int curent_patch_cc = current_semver.patch()/100; + int cached_patch_cc = cached_semver.patch()/100; + int curent_patch_dd = current_semver.patch()%100; + int cached_patch_dd = cached_semver.patch()%100; + if ((cached_semver.maj() != current_semver.maj()) + || (cached_semver.min() != current_semver.min()) + || (curent_patch_cc != cached_patch_cc)) + { + need_delete_cache = true; + BOOST_LOG_TRIVIAL(info) << boost::format("cached plugins version %1% not match with current %2%")%cached_version%curr_version; + } + else if (cached_patch_dd <= curent_patch_dd) { + need_delete_cache = true; + BOOST_LOG_TRIVIAL(info) << boost::format("cached plugins version %1% not newer than current %2%")%cached_version%curr_version; + } + else { + plugin_version = cached_version; + } + + if (need_delete_cache) { + std::string data_dir_str = data_dir(); + boost::filesystem::path data_dir_path(data_dir_str); + auto cache_folder = data_dir_path / "ota"; + +#if defined(_MSC_VER) || defined(_WIN32) + auto network_library = cache_folder / "bambu_networking.dll"; + auto player_library = cache_folder / "BambuSource.dll"; +#elif defined(__WXMAC__) + auto network_library = cache_folder / "libbambu_networking.dylib"; + auto player_library = cache_folder / "libBambuSource.dylib"; +#else + auto network_library = cache_folder / "libbambu_networking.so"; + auto player_library = cache_folder / "libBambuSource.so"; +#endif + auto changelog_file = cache_folder / "network_plugins.json"; + + if (boost::filesystem::exists(network_library)) + { + + BOOST_LOG_TRIVIAL(info) << "[remove_old_networking_plugins] remove the file "< resources