mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-08-30 05:17:19 +00:00
Add CI\CD step to prepare cache file in ahead of time so user does not need to wait
This commit is contained in:
@@ -2273,6 +2273,26 @@ std::pair<PresetsConfigSubstitutions, std::string> PresetBundle::load_system_pre
|
||||
BOOST_LOG_TRIVIAL(info) << "PresetBundle: system presets loaded from cache in " << ms << " ms";
|
||||
return {PresetsConfigSubstitutions{}, ""};
|
||||
}
|
||||
|
||||
// Try bundled cache shipped with the installer (first launch, before user cache exists).
|
||||
// Validates against resources/profiles/ — the same directory it was generated from in CI.
|
||||
{
|
||||
const std::string bundled_dir =
|
||||
(boost::filesystem::path(resources_dir()) / "profiles").make_preferred().string();
|
||||
PresetBundleCache::SystemPresetsCache bundled;
|
||||
if (bundled.load(PresetBundleCache::SystemPresetsCache::bundled_cache_path()) &&
|
||||
bundled.is_valid(bundled_dir)) {
|
||||
bundled.apply(*this);
|
||||
update_system_maps();
|
||||
// Promote to user cache so subsequent launches skip this check.
|
||||
bundled.save(cache_file);
|
||||
const auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
std::chrono::steady_clock::now() - t0).count();
|
||||
BOOST_LOG_TRIVIAL(info) << "PresetBundle: system presets loaded from bundled cache in " << ms << " ms";
|
||||
return {PresetsConfigSubstitutions{}, ""};
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " cache miss, falling back to JSON load";
|
||||
}
|
||||
|
||||
|
||||
@@ -116,6 +116,12 @@ std::string SystemPresetsCache::cache_path()
|
||||
.make_preferred().string();
|
||||
}
|
||||
|
||||
std::string SystemPresetsCache::bundled_cache_path()
|
||||
{
|
||||
return (boost::filesystem::path(resources_dir()) / "profiles" / "system_presets_cache.cache")
|
||||
.make_preferred().string();
|
||||
}
|
||||
|
||||
bool SystemPresetsCache::is_valid(const std::string& system_dir) const
|
||||
{
|
||||
if (format_version != FORMAT_VERSION)
|
||||
|
||||
@@ -119,6 +119,7 @@ struct SystemPresetsCache {
|
||||
}
|
||||
|
||||
static std::string cache_path();
|
||||
static std::string bundled_cache_path();
|
||||
bool is_valid(const std::string& system_dir) const;
|
||||
void capture(const PresetBundle& bundle, const std::string& system_dir);
|
||||
void apply(PresetBundle& bundle) const;
|
||||
|
||||
Reference in New Issue
Block a user