From f088a18167984d9932aaf8cca5e5d357a4fc8bd3 Mon Sep 17 00:00:00 2001 From: ExPikaPaka Date: Thu, 18 Jun 2026 10:38:05 +0200 Subject: [PATCH] Remove leftover cache file --- .github/workflows/build_orca.yml | 5 ++ build_linux.sh | 2 + src/libslic3r/PresetBundle.hpp | 2 +- src/libslic3r/Semver.hpp | 5 +- src/slic3r/GUI/WebGuideDialog.cpp | 111 ++---------------------------- src/slic3r/GUI/WebGuideDialog.hpp | 2 - 6 files changed, 18 insertions(+), 109 deletions(-) diff --git a/.github/workflows/build_orca.yml b/.github/workflows/build_orca.yml index 2f8ad0808c..d0f977bdc9 100644 --- a/.github/workflows/build_orca.yml +++ b/.github/workflows/build_orca.yml @@ -310,6 +310,11 @@ jobs: $profiles = Get-ChildItem -Recurse -Path build -Directory -Filter profiles | Where-Object { $_.FullName -match 'resources' } | Select-Object -First 1 if (-not $profiles) { Write-Error "profiles directory not found in build tree"; exit 1 } + # Add the slicer's runtime DLL directory to PATH so generate_system_cache.exe + # can resolve its dependencies (TKernel.dll etc.) without a full install step. + $dll_dir = Get-ChildItem -Recurse -Path build -Filter "TKernel.dll" | + Select-Object -First 1 | Select-Object -ExpandProperty DirectoryName + if ($dll_dir) { $env:PATH = "$dll_dir;$env:PATH" } & $tool.FullName --path $profiles.FullName --log_level 2 - name: Create installer Win diff --git a/build_linux.sh b/build_linux.sh index 72ea742f1a..6d65a10e41 100755 --- a/build_linux.sh +++ b/build_linux.sh @@ -567,6 +567,8 @@ if [[ -n "${BUILD_ORCA}" ]] || [[ -n "${BUILD_TESTS}" ]] ; then print_and_run cmake --build $BUILD_DIR --config "${BUILD_CONFIG}" --target OrcaSlicer echo "Building OrcaSlicer_profile_validator .." print_and_run cmake --build $BUILD_DIR --config "${BUILD_CONFIG}" --target OrcaSlicer_profile_validator + echo "Building generate_system_cache ..." + print_and_run cmake --build $BUILD_DIR --config "${BUILD_CONFIG}" --target generate_system_cache ./scripts/run_gettext.sh fi if [[ -n "${BUILD_TESTS}" ]] ; then diff --git a/src/libslic3r/PresetBundle.hpp b/src/libslic3r/PresetBundle.hpp index c464de38db..6ce69f4b66 100644 --- a/src/libslic3r/PresetBundle.hpp +++ b/src/libslic3r/PresetBundle.hpp @@ -161,7 +161,7 @@ public: struct VendorCache { static constexpr uint32_t CACHE_MAGIC = 0x4F52435A; // "ORCZ" - static constexpr uint32_t CACHE_VERSION = 4; // bumped: Preset/VendorProfile serialize directly + static constexpr uint32_t CACHE_VERSION = 5; // bumped: Semver serialized as 3-part (to_string_sf) uint32_t cache_version = CACHE_VERSION; uint32_t config_options_count = 0; // fixed-width: size_t varies between 32/64-bit builds diff --git a/src/libslic3r/Semver.hpp b/src/libslic3r/Semver.hpp index a8a46a0d67..1e75c57ad0 100644 --- a/src/libslic3r/Semver.hpp +++ b/src/libslic3r/Semver.hpp @@ -191,9 +191,10 @@ public: return os; } - // cereal: round-trip through the string representation + // cereal: round-trip through the standard 3-part string (major.minor.patch). + // to_string() uses a BBS 4-part format that semver_parse() cannot read back. template - std::string save_minimal(const Archive&) const { return to_string(); } + std::string save_minimal(const Archive&) const { return to_string_sf(); } template void load_minimal(const Archive&, const std::string& s) { if (auto v = Semver::parse(s)) *this = std::move(*v); diff --git a/src/slic3r/GUI/WebGuideDialog.cpp b/src/slic3r/GUI/WebGuideDialog.cpp index 455ec06185..6bb077c770 100644 --- a/src/slic3r/GUI/WebGuideDialog.cpp +++ b/src/slic3r/GUI/WebGuideDialog.cpp @@ -347,20 +347,12 @@ void GuideFrame::OnNavigationComplete(wxWebViewEvent &evt) if (!bFirstComplete) { bFirstComplete = true; try { - // Steps 1 and 2 run on the main thread: safe to access preset_bundle and - // filesystem. Only fall through to the background thread for slow paths. init_guide_paths(); - const bool cache_hit = try_load_guide_cache(); - if (cache_hit) { + if (BuildProfileDataFromPresetBundle()) { if (!m_destroy) on_profile_loaded(); - } else if (BuildProfileDataFromPresetBundle()) { - if (!m_destroy) { - save_guide_cache(); - on_profile_loaded(); - } } else { - // Steps 3+4 are slow — delegate to background thread. + // Presets not yet in memory — delegate to background thread. m_load_task = std::make_unique(boost::bind(&GuideFrame::LoadProfileData, this)); } } catch (const std::exception& e) { @@ -1319,62 +1311,6 @@ bool GuideFrame::BuildProfileDataFromPresetBundle() } } -static std::string guide_cache_path() -{ - // Keep this out of data_dir/system/ — that directory is scanned for vendor JSONs - // and a non-vendor JSON there crashes get_version_from_json() on startup. - return (boost::filesystem::path(Slic3r::data_dir()) / "guide_profile_cache.json") - .make_preferred().string(); -} - -// Tries to load the user-side guide profile JSON cache. -// Returns true and populates m_ProfileJson on cache hit. -bool GuideFrame::try_load_guide_cache() -{ - const std::string path = guide_cache_path(); - if (!boost::filesystem::exists(path)) - return false; - try { - std::string contents; - if (!LoadFile(path, contents)) - return false; - const json cache = json::parse(contents); - if (!cache.contains("vendor_versions") || !cache.contains("profile_data")) - return false; - - const json& vv = cache["vendor_versions"]; - - // Every vendor in the cache must still have the same version. - for (const auto& [filename, cached_ver] : vv.items()) { - boost::filesystem::path fp = rsrc_vendor_dir / filename; - if (!boost::filesystem::exists(fp)) - fp = vendor_dir / filename; - if (!boost::filesystem::exists(fp)) - return false; - const Semver disk_ver = get_version_from_json(fp.string()); - const std::string disk_ver_str = disk_ver.valid() ? disk_ver.to_string() : ""; - if (disk_ver_str != cached_ver.get()) - return false; - } - - // No new vendor JSONs must have appeared since the cache was built. - for (const auto* dir_ptr : {&rsrc_vendor_dir, &vendor_dir}) { - for (const auto& e : boost::filesystem::directory_iterator(*dir_ptr)) { - if (e.path().extension().string() != ".json") continue; - if (!vv.contains(e.path().filename().string())) - return false; - } - } - - m_ProfileJson = cache["profile_data"]; - BOOST_LOG_TRIVIAL(info) << "GuideFrame: guide profile cache hit: " << path; - return true; - } catch (const std::exception& ex) { - BOOST_LOG_TRIVIAL(warning) << "GuideFrame: guide cache load failed: " << ex.what(); - return false; - } -} - // Builds guide profile JSON from the per-vendor bundled caches // (resources/profiles/.cache, generated by CI). // This avoids the 90-second LoadProfileFamily fallback on first launch. @@ -1399,8 +1335,7 @@ bool GuideFrame::BuildProfileDataFromBundledCache() const std::string vendor_id = cache_path.stem().string(); // Validate against the version in the corresponding vendor JSON. const boost::filesystem::path json_path = rsrc_vendor_dir / (vendor_id + ".json"); - const Semver ver = get_version_from_json(json_path.string()); - const std::string ver_str = ver.valid() ? ver.to_string() : ""; + const std::string ver_str = get_vendor_cache_key(json_path.string()); PresetBundle::VendorCache vc; if (!vc.load(cache_path.string()) || !vc.is_valid(ver_str)) @@ -1505,43 +1440,15 @@ bool GuideFrame::BuildProfileDataFromBundledCache() } } -void GuideFrame::save_guide_cache() const -{ - try { - json cache; - // Record version strings (not mtimes) so the cache is portable - // across machines and survives file extraction timestamp changes. - for (const auto* dir_ptr : {&rsrc_vendor_dir, &vendor_dir}) { - for (const auto& e : boost::filesystem::directory_iterator(*dir_ptr)) { - if (e.path().extension().string() != ".json") continue; - // Store version for all files, including version-less ones (empty string). - // try_load_guide_cache checks ALL json files, so blacklist.json etc. must be present. - const Semver ver = get_version_from_json(e.path().string()); - cache["vendor_versions"][e.path().filename().string()] = - ver.valid() ? ver.to_string() : ""; - } - } - cache["profile_data"] = m_ProfileJson; - - boost::filesystem::create_directories( - boost::filesystem::path(guide_cache_path()).parent_path()); - boost::nowide::ofstream ofs(guide_cache_path()); - ofs << cache.dump(-1, ' ', false, json::error_handler_t::ignore); - BOOST_LOG_TRIVIAL(info) << "GuideFrame: guide profile cache saved to " << guide_cache_path(); - } catch (const std::exception& e) { - BOOST_LOG_TRIVIAL(warning) << "GuideFrame: guide cache save failed: " << e.what(); - } -} - int GuideFrame::LoadProfileData() { - // Background thread: Steps 1+2 already ran on the main thread in OnNavigationComplete - // and both failed. This function handles only Steps 3 (bundled cache) and 4 (slow JSON walk). + // Background thread: the fast path in OnNavigationComplete failed (presets not yet loaded). + // Try bundled per-vendor caches first, then fall back to reading all vendor JSONs. try { - // Step 3: bundled system preset cache (CI-generated, ~1-2s) + // Bundled system preset cache (CI-generated, ~1-2s) bool slow_path = !BuildProfileDataFromBundledCache(); if (slow_path) { - // Step 4: last resort — read all vendor JSONs (~90s) + // Last resort — read all vendor JSONs (~90s) std::set loaded_vendors; auto filament_library_name = boost::filesystem::path(PresetBundle::ORCA_FILAMENT_LIBRARY).replace_extension(".json"); if (boost::filesystem::exists(vendor_dir / filament_library_name)) @@ -1581,10 +1488,6 @@ int GuideFrame::LoadProfileData() } } - // Promote to user guide cache so every subsequent open takes ~50ms. - if (!m_destroy) - save_guide_cache(); - // Capture the cancel token by value (shared_ptr) so the lambda doesn't // touch `this` if GuideFrame is destroyed before the event fires. auto tok = m_cancel_token; diff --git a/src/slic3r/GUI/WebGuideDialog.hpp b/src/slic3r/GUI/WebGuideDialog.hpp index f063596ad9..fd92ec756e 100644 --- a/src/slic3r/GUI/WebGuideDialog.hpp +++ b/src/slic3r/GUI/WebGuideDialog.hpp @@ -86,8 +86,6 @@ public: void on_profile_loaded(); bool BuildProfileDataFromPresetBundle(); bool BuildProfileDataFromBundledCache(); - bool try_load_guide_cache(); - void save_guide_cache() const; int SaveProfile(); int GetFilamentInfo( std::string VendorDirectory,json & pFilaList, std::string filepath, std::string &sVendor, std::string &sType);