feat: Update 2 files
This commit is contained in:
@@ -100,7 +100,8 @@ int edit_config()
|
|||||||
if (!gConfig().is_config_set())
|
if (!gConfig().is_config_set())
|
||||||
return return_die("Failed to load and parse edited config file!");
|
return return_die("Failed to load and parse edited config file!");
|
||||||
|
|
||||||
gConfig().save_config(true);
|
// Don't save_config after loading - it would rewrite the file the user just edited!
|
||||||
|
// The config is already saved by the editor, we just validated it by loading it.
|
||||||
|
|
||||||
std::cout << "Successfully edited config file at " << config_file << std::endl;
|
std::cout << "Successfully edited config file at " << config_file << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -129,13 +129,12 @@
|
|||||||
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)) {
|
||||||
info << "Template '" << template_name << "' found in cache at " << template_cache_dir << std::endl;
|
// Template found in cache
|
||||||
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;
|
||||||
@@ -157,11 +156,7 @@
|
|||||||
}
|
}
|
||||||
std::filesystem::remove(temp_file);
|
std::filesystem::remove(temp_file);
|
||||||
} else {
|
} else {
|
||||||
warning << "curl command failed for URL: " << check_url << " (exit code: " << result << ")" << std::endl;
|
// curl failed - network issue or server down
|
||||||
// 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 {
|
||||||
@@ -169,12 +164,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!json_response.is_null() && json_response.contains("exists")) {
|
if (!json_response.is_null() && json_response.contains("exists")) {
|
||||||
bool exists = json_response["exists"].get<bool>();
|
return 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);
|
||||||
}
|
}
|
||||||
@@ -545,9 +537,7 @@
|
|||||||
|
|
||||||
// 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();
|
||||||
info << "Loading " << registry_urls.size() << " template registry sources" << std::endl;
|
|
||||||
for (const auto& url : registry_urls) {
|
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user