Update source/src/templates.cpp
All checks were successful
Build-Test-Publish / build (linux/amd64) (push) Successful in 41s
Build-Test-Publish / build (linux/arm64) (push) Successful in 1m15s

This commit is contained in:
Your Name
2025-08-24 21:50:38 +12:00
parent 0735683162
commit 657dea1f19

View File

@@ -525,12 +525,18 @@
ASSERT(mSources.empty(), "Template manager already loaded (sources are not empty).");
ASSERT(gConfig().is_config_set(), "Config not set.");
ASSERT(!mLoaded, "Template manager already loaded.");
auto local_template_paths = gConfig().get_local_template_paths();
if (local_template_paths.empty())
return;
for (const auto& path : local_template_paths)
mSources.push_back(std::make_unique<template_source_local>(path));
// Add local template sources only if the paths exist and are directories
auto local_template_paths = gConfig().get_local_template_paths();
for (const auto& path : local_template_paths) {
if (std::filesystem::exists(path) && std::filesystem::is_directory(path)) {
mSources.push_back(std::make_unique<template_source_local>(path));
} else {
info << "Skipping non-existent or invalid local template path: " << path << std::endl;
}
}
// Add registry sources - these should always be added
auto registry_urls = gConfig().get_template_registry_urls();
for (const auto& url : registry_urls)
mSources.push_back(std::make_unique<template_source_registry>(url));