create-config option
This commit is contained in:
@@ -140,7 +140,7 @@ void _append(std::vector<std::string> & a, const std::vector<std::string> & b) {
|
||||
a.insert(std::end(a), std::begin(b), std::end(b));
|
||||
}
|
||||
|
||||
bool config::save_config(bool create_aux_directories)
|
||||
bool config::save_config()
|
||||
{
|
||||
std::string config_path = localfile::dropshell_json();
|
||||
if (config_path.empty())
|
||||
@@ -177,18 +177,6 @@ bool config::save_config(bool create_aux_directories)
|
||||
config_file << mConfig.dump(4);
|
||||
config_file.close();
|
||||
|
||||
if (create_aux_directories) {
|
||||
std::vector<std::string> paths;
|
||||
_append(paths, get_local_template_paths());
|
||||
_append(paths, get_local_server_definition_paths());
|
||||
for (auto & p : paths)
|
||||
if (!std::filesystem::exists(p))
|
||||
{
|
||||
std::cout << "Creating directory: " << p << std::endl;
|
||||
std::filesystem::create_directories(p);
|
||||
}
|
||||
}
|
||||
|
||||
debug << "Config paths: " << std::endl;
|
||||
for (auto [key,value] : mConfig.items()) {
|
||||
debug << " " << key << ": " << value << std::endl;
|
||||
@@ -197,6 +185,19 @@ bool config::save_config(bool create_aux_directories)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool config::create_aux_directories()
|
||||
{
|
||||
std::vector<std::string> paths;
|
||||
_append(paths, get_local_template_paths());
|
||||
_append(paths, get_local_server_definition_paths());
|
||||
for (auto & p : paths)
|
||||
if (!std::filesystem::exists(p))
|
||||
{
|
||||
info << "Creating directory: " << p << std::endl;
|
||||
std::filesystem::create_directories(p);
|
||||
}
|
||||
}
|
||||
|
||||
bool config::is_config_set() const
|
||||
{
|
||||
return mIsConfigSet;
|
||||
@@ -343,13 +344,13 @@ void config::set_server_disabled(const std::string &server_name, bool disabled)
|
||||
// Add to disabled list if not already there
|
||||
if (it == disabled_servers.end()) {
|
||||
disabled_servers.push_back(server_name);
|
||||
save_config(false); // Save immediately
|
||||
save_config(); // Save immediately
|
||||
}
|
||||
} else {
|
||||
// Remove from disabled list if present
|
||||
if (it != disabled_servers.end()) {
|
||||
disabled_servers.erase(it);
|
||||
save_config(false); // Save immediately
|
||||
save_config(); // Save immediately
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user