From b506aa11fab60fa5413fc82d3615e15a7a9624ea Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Tue, 17 Apr 2018 10:28:32 +0200 Subject: [PATCH] PresetUpdater: Fix: Compare versions when installing indices --- xs/src/slic3r/Utils/PresetUpdater.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/xs/src/slic3r/Utils/PresetUpdater.cpp b/xs/src/slic3r/Utils/PresetUpdater.cpp index 3291af7e03..dc3b95d798 100644 --- a/xs/src/slic3r/Utils/PresetUpdater.cpp +++ b/xs/src/slic3r/Utils/PresetUpdater.cpp @@ -220,9 +220,16 @@ void PresetUpdater::priv::check_install_indices() const if (path.extension() == ".idx") { const auto path_in_cache = cache_path / path.filename(); - // TODO: compare versions if (! fs::exists(path_in_cache)) { fs::copy_file(path, path_in_cache, fs::copy_option::overwrite_if_exists); + } else { + Index idx_rsrc, idx_cache; + idx_rsrc.load(path); + idx_cache.load(path_in_cache); + + if (idx_cache.version() < idx_rsrc.version()) { + fs::copy_file(path, path_in_cache, fs::copy_option::overwrite_if_exists); + } } } } @@ -267,8 +274,6 @@ Updates PresetUpdater::priv::config_update() const const auto cached_vp = VendorProfile::from_ini(path_in_cache, false); if (cached_vp.config_version == recommended->config_version) { updates.emplace_back(std::move(path_in_cache), bundle_path, *recommended); - } else { - // XXX: ? } } }