From e8efe73f4af7cac2da5b5fe0c9c14e629f232784 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 25 Aug 2025 20:39:36 +1200 Subject: [PATCH] feat: Update 2 files --- source/src/commands/edit.cpp | 3 ++- source/src/templates.cpp | 16 +++------------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/source/src/commands/edit.cpp b/source/src/commands/edit.cpp index 968bcc0..84b9aee 100644 --- a/source/src/commands/edit.cpp +++ b/source/src/commands/edit.cpp @@ -100,7 +100,8 @@ int edit_config() if (!gConfig().is_config_set()) 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; return 0; diff --git a/source/src/templates.cpp b/source/src/templates.cpp index c04d162..6666a9b 100644 --- a/source/src/templates.cpp +++ b/source/src/templates.cpp @@ -129,13 +129,12 @@ 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)) { - info << "Template '" << template_name << "' found in cache at " << template_cache_dir << std::endl; + // Template found in cache 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; @@ -157,11 +156,7 @@ } std::filesystem::remove(temp_file); } else { - 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()); + // curl failed - network issue or server down return std::filesystem::exists(template_cache_dir); } } else { @@ -169,12 +164,9 @@ } if (!json_response.is_null() && json_response.contains("exists")) { - bool exists = json_response["exists"].get(); - info << "Registry response: template '" << template_name << "' exists = " << (exists ? "true" : "false") << std::endl; - return exists; + return json_response["exists"].get(); } - 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); } @@ -545,9 +537,7 @@ // Add registry sources - these should always be added auto registry_urls = gConfig().get_template_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)); }