Add CI\CD step to prepare cache file in ahead of time so user does not need to wait

This commit is contained in:
ExPikaPaka
2026-06-15 09:19:53 +02:00
committed by SoftFever
parent 25b1577c45
commit 6b3e4f18e1
6 changed files with 149 additions and 0 deletions

View File

@@ -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";
}

View File

@@ -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)

View File

@@ -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;