diff --git a/source/src/templates.cpp b/source/src/templates.cpp index db40ab9..54c8873 100644 --- a/source/src/templates.cpp +++ b/source/src/templates.cpp @@ -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."); + + // Add local template sources only if the paths exist and are directories 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(path)); + for (const auto& path : local_template_paths) { + if (std::filesystem::exists(path) && std::filesystem::is_directory(path)) { + mSources.push_back(std::make_unique(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(url));