Update source/src/templates.cpp
This commit is contained in:
@@ -129,12 +129,13 @@
|
|||||||
std::filesystem::path cache_dir = get_cache_dir();
|
std::filesystem::path cache_dir = get_cache_dir();
|
||||||
std::filesystem::path template_cache_dir = cache_dir / template_name;
|
std::filesystem::path template_cache_dir = cache_dir / template_name;
|
||||||
if (std::filesystem::exists(template_cache_dir)) {
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if template exists in registry
|
// Check if template exists in registry
|
||||||
std::string check_url = mRegistry.url + "/exists/" + template_name + ":latest";
|
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
|
// For HTTPS URLs, use curl to fetch the JSON
|
||||||
nlohmann::json json_response;
|
nlohmann::json json_response;
|
||||||
@@ -156,8 +157,11 @@
|
|||||||
}
|
}
|
||||||
std::filesystem::remove(temp_file);
|
std::filesystem::remove(temp_file);
|
||||||
} else {
|
} else {
|
||||||
// curl failed - might be network issue or server down
|
warning << "curl command failed for URL: " << check_url << " (exit code: " << result << ")" << std::endl;
|
||||||
// Check cache as fallback
|
// 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);
|
return std::filesystem::exists(template_cache_dir);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -165,9 +169,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!json_response.is_null() && json_response.contains("exists")) {
|
if (!json_response.is_null() && json_response.contains("exists")) {
|
||||||
return json_response["exists"].get<bool>();
|
bool exists = json_response["exists"].get<bool>();
|
||||||
|
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
|
// If registry check failed but we have cache, use cache
|
||||||
return std::filesystem::exists(template_cache_dir);
|
return std::filesystem::exists(template_cache_dir);
|
||||||
}
|
}
|
||||||
@@ -538,8 +545,11 @@
|
|||||||
|
|
||||||
// Add registry sources - these should always be added
|
// Add registry sources - these should always be added
|
||||||
auto registry_urls = gConfig().get_template_registry_urls();
|
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<template_source_registry>(url));
|
mSources.push_back(std::make_unique<template_source_registry>(url));
|
||||||
|
}
|
||||||
|
|
||||||
mLoaded = true;
|
mLoaded = true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user