diff --git a/source/src/templates.cpp b/source/src/templates.cpp index 54c8873..c04d162 100644 --- a/source/src/templates.cpp +++ b/source/src/templates.cpp @@ -129,12 +129,13 @@ std::filesystem::path cache_dir = get_cache_dir(); std::filesystem::path template_cache_dir = cache_dir / template_name; if (std::filesystem::exists(template_cache_dir)) { - // We have it cached, so return true + info << "Template '" << template_name << "' found in cache at " << template_cache_dir << std::endl; return true; } // Check if template exists in registry std::string check_url = mRegistry.url + "/exists/" + template_name + ":latest"; + info << "Checking registry for template '" << template_name << "' at: " << check_url << std::endl; // For HTTPS URLs, use curl to fetch the JSON nlohmann::json json_response; @@ -156,8 +157,11 @@ } std::filesystem::remove(temp_file); } else { - // curl failed - might be network issue or server down - // Check cache as fallback + warning << "curl command failed for URL: " << check_url << " (exit code: " << result << ")" << std::endl; + // Try without silent mode to see what's happening + std::string debug_cmd = "curl -L " + quote(check_url) + " 2>&1"; + info << "Debugging with: " << debug_cmd << std::endl; + system(debug_cmd.c_str()); return std::filesystem::exists(template_cache_dir); } } else { @@ -165,9 +169,12 @@ } if (!json_response.is_null() && json_response.contains("exists")) { - return json_response["exists"].get(); + bool exists = json_response["exists"].get(); + info << "Registry response: template '" << template_name << "' exists = " << (exists ? "true" : "false") << std::endl; + return exists; } + warning << "Failed to get valid response from registry for template: " << template_name << std::endl; // If registry check failed but we have cache, use cache return std::filesystem::exists(template_cache_dir); } @@ -538,8 +545,11 @@ // Add registry sources - these should always be added auto registry_urls = gConfig().get_template_registry_urls(); - for (const auto& url : registry_urls) + info << "Loading " << registry_urls.size() << " template registry sources" << std::endl; + for (const auto& url : registry_urls) { + info << "Adding registry source: " << url.name << " at " << url.url << std::endl; mSources.push_back(std::make_unique(url)); + } mLoaded = true; }