fix: Always update template list file even if path already registered

This commit is contained in:
j
2026-03-26 21:56:20 +13:00
parent 63fdc2c0cb
commit 74329dd968

View File

@@ -141,15 +141,18 @@ int add_template_handler(const CommandContext& ctx) {
} }
// 6. Check if this path or a parent is already registered // 6. Check if this path or a parent is already registered
bool already_registered = false;
for (const auto& entry : j) { for (const auto& entry : j) {
if (!entry.is_string()) continue; if (!entry.is_string()) continue;
std::string existing = entry_local_path(entry.get<std::string>()); std::string existing = entry_local_path(entry.get<std::string>());
if (is_same_or_child(local_path, existing)) { if (is_same_or_child(local_path, existing)) {
info << "Already covered by existing entry: " << existing << std::endl; info << "Already registered: " << existing << std::endl;
return 0; already_registered = true;
break;
} }
} }
if (!already_registered) {
// 7. Auto-detect git remote URL // 7. Auto-detect git remote URL
std::string git_url; std::string git_url;
if (!git_root.empty()) { if (!git_root.empty()) {
@@ -183,15 +186,11 @@ int add_template_handler(const CommandContext& ctx) {
info << "Added to " << json_path << ":" << std::endl; info << "Added to " << json_path << ":" << std::endl;
info << " " << new_entry << std::endl; info << " " << new_entry << std::endl;
// 10. Create dropshell-templates.list if it doesn't exist
std::filesystem::path list_file = dir_path / filenames::dropshell_templates_list;
if (!std::filesystem::exists(list_file)) {
gTemplateManager().write_list_file(local_path, templates);
} else {
info << "Using existing " << list_file << std::endl;
} }
// 10. Always update dropshell-templates.list with discovered templates
gTemplateManager().write_list_file(local_path, templates);
info << "Found " << templates.size() << " template(s)" << std::endl; info << "Found " << templates.size() << " template(s)" << std::endl;
return 0; return 0;