Remove bogus servers

This commit is contained in:
Your Name 2025-05-04 20:04:47 +12:00
parent 008cf59c48
commit aeaf57e196
3 changed files with 7 additions and 1 deletions

View File

@ -138,10 +138,13 @@ std::vector<std::string> config::get_template_local_paths()
std::vector<std::string> config::get_local_server_definition_paths() {
nlohmann::json server_definition_paths = mConfig["server_definition_paths"];
std::vector<std::string> paths;
for (auto &path : server_definition_paths) {
if (path.is_string() && !path.empty())
{
paths.push_back(path);
}
else
std::cerr << "Warning: Invalid server definition path: " << path << std::endl;
}

View File

@ -29,6 +29,9 @@ std::vector<ServerInfo> get_configured_servers() {
if (std::filesystem::is_directory(entry)) {
std::string server_name = entry.path().filename().string();
if (server_name.empty() || server_name[0]=='.' || server_name[0]=='_')
continue;
server_env_manager env(server_name);
if (!env.is_valid()) {
std::cerr << "Error: Invalid server environment file: " << entry.path().string() << std::endl;

View File

@ -45,10 +45,10 @@ namespace localfile {
namespace localpath {
std::string server(const std::string &server_name) {
if (server_name.empty()) return "";
for (std::filesystem::path dir : gConfig().get_local_server_definition_paths())
if (fs::exists(dir / server_name))
return dir / server_name;
return "";
}