fix: Always update template list file even if path already registered
This commit is contained in:
@@ -141,15 +141,18 @@ int add_template_handler(const CommandContext& ctx) {
|
||||
}
|
||||
|
||||
// 6. Check if this path or a parent is already registered
|
||||
bool already_registered = false;
|
||||
for (const auto& entry : j) {
|
||||
if (!entry.is_string()) continue;
|
||||
std::string existing = entry_local_path(entry.get<std::string>());
|
||||
if (is_same_or_child(local_path, existing)) {
|
||||
info << "Already covered by existing entry: " << existing << std::endl;
|
||||
return 0;
|
||||
info << "Already registered: " << existing << std::endl;
|
||||
already_registered = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!already_registered) {
|
||||
// 7. Auto-detect git remote URL
|
||||
std::string git_url;
|
||||
if (!git_root.empty()) {
|
||||
@@ -183,15 +186,11 @@ int add_template_handler(const CommandContext& ctx) {
|
||||
|
||||
info << "Added to " << json_path << ":" << 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;
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user