linux fixes
Some checks failed
Blockstorage/repertory/pipeline/head There was a failure building this commit
BlockStorage/repertory/pipeline/head There was a failure building this commit

This commit is contained in:
2025-09-15 12:17:49 -05:00
parent f722dd4b84
commit bc9e4fc95a
4 changed files with 28 additions and 15 deletions

View File

@@ -36,10 +36,11 @@ private:
private: private:
std::atomic<bool> animations_{true}; std::atomic<bool> animations_{true};
utils::atomic<std::string> api_password_{REPERTORY}; utils::atomic<std::string> api_password_{std::string{REPERTORY}};
std::atomic<std::uint16_t> api_port_{default_ui_mgmt_port}; std::atomic<std::uint16_t> api_port_{default_ui_mgmt_port};
utils::atomic<std::string> api_user_{REPERTORY}; utils::atomic<std::string> api_user_{std::string{REPERTORY}};
std::atomic<bool> auto_start_{true}; std::atomic<bool> auto_start_{true};
std::atomic<event_level> event_level_{event_level::info};
std::unordered_map<provider_type, std::unordered_map<provider_type,
std::unordered_map<std::string, std::string>> std::unordered_map<std::string, std::string>>
locations_; locations_;
@@ -71,6 +72,10 @@ public:
[[nodiscard]] auto get_auto_start_list() const [[nodiscard]] auto get_auto_start_list() const
-> std::unordered_map<provider_type, std::vector<std::string>>; -> std::unordered_map<provider_type, std::vector<std::string>>;
[[nodiscard]] auto get_event_level() const -> event_level {
return event_level_;
}
[[nodiscard]] auto get_hidden() const -> bool { return hidden_; } [[nodiscard]] auto get_hidden() const -> bool { return hidden_; }
[[nodiscard]] auto get_launch_only() const -> bool { return launch_only_; } [[nodiscard]] auto get_launch_only() const -> bool { return launch_only_; }
@@ -92,6 +97,8 @@ public:
void set_auto_start(provider_type prov, std::string_view name, void set_auto_start(provider_type prov, std::string_view name,
bool auto_start); bool auto_start);
void set_event_level(event_level level);
void set_hidden(bool hidden); void set_hidden(bool hidden);
void set_launch_only(bool launch_only); void set_launch_only(bool launch_only);

View File

@@ -29,6 +29,7 @@
#include "ui/mgmt_app_config.hpp" #include "ui/mgmt_app_config.hpp"
#include "ui/ui_server.hpp" #include "ui/ui_server.hpp"
#include "utils/cli_utils.hpp" #include "utils/cli_utils.hpp"
#include "utils/error_utils.hpp"
#include "utils/polling.hpp" #include "utils/polling.hpp"
using namespace repertory; using namespace repertory;
@@ -83,7 +84,7 @@ auto main(int argc, char **argv) -> int {
const auto run_ui = [](auto *server) { const auto run_ui = [](auto *server) {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
static std::atomic<ui::server *> active_server{server}; static std::atomic<ui::ui_server *> active_server{server};
static const auto quit_handler = [](int /* sig */) { static const auto quit_handler = [](int /* sig */) {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
@@ -106,13 +107,13 @@ auto main(int argc, char **argv) -> int {
std::signal(SIGTERM, quit_handler); std::signal(SIGTERM, quit_handler);
try { try {
ptr->start(); server->start();
} catch (const std::exception &ex) { } catch (const std::exception &ex) {
utils::error::raise_error(function_name, ex, "failed to start ui"); utils::error::raise_error(function_name, ex, "failed to start ui");
} }
try { try {
ptr->stop(); server->stop();
} catch (const std::exception &ex) { } catch (const std::exception &ex) {
utils::error::raise_error(function_name, ex, "failed to stop ui"); utils::error::raise_error(function_name, ex, "failed to stop ui");
} }
@@ -136,7 +137,7 @@ auto main(int argc, char **argv) -> int {
return -1; return -1;
} }
ui::server server(&config); ui::ui_server server(&config);
run_ui(&server); run_ui(&server);
return 0; return 0;
}); });

View File

@@ -112,6 +112,13 @@ mgmt_app_config::mgmt_app_config(bool hidden, bool launch_only)
should_save = true; should_save = true;
} }
if (data.contains(JSON_EVENT_LEVEL)) {
event_level_ = event_level_from_string(
data.at(JSON_EVENT_LEVEL).get<std::string>());
} else {
should_save = true;
}
if (data.contains(JSON_MOUNT_LOCATIONS)) { if (data.contains(JSON_MOUNT_LOCATIONS)) {
locations_ = from_json<std::string>(data.at(JSON_MOUNT_LOCATIONS)); locations_ = from_json<std::string>(data.at(JSON_MOUNT_LOCATIONS));
} else { } else {
@@ -253,7 +260,8 @@ void mgmt_app_config::set_auto_start(bool auto_start) {
cfg.comment = "Mount utility for AWS S3 and Sia"; cfg.comment = "Mount utility for AWS S3 and Sia";
cfg.exec_args = {"-ui", "-lo"}; cfg.exec_args = {"-ui", "-lo"};
cfg.exec_path = utils::path::combine(".", {REPERTORY}); cfg.exec_path = utils::path::combine(".", {REPERTORY});
cfg.icon_path = utils::path::combine(".", {REPERTORY ".png"}); cfg.icon_path =
utils::path::combine(".", {std::string{REPERTORY} + ".png"});
cfg.terminal = true; cfg.terminal = true;
if (utils::create_autostart_entry(cfg, false)) { if (utils::create_autostart_entry(cfg, false)) {
@@ -365,6 +373,10 @@ void mgmt_app_config::set_auto_start(provider_type prov, std::string_view name,
save(); save();
} }
void mgmt_app_config::set_event_level(event_level level) {
event_level_ = level;
}
void mgmt_app_config::set_hidden(bool hidden) { hidden_ = hidden; } void mgmt_app_config::set_hidden(bool hidden) { hidden_ = hidden; }
void mgmt_app_config::set_launch_only(bool launch_only) { void mgmt_app_config::set_launch_only(bool launch_only) {
@@ -395,6 +407,7 @@ auto mgmt_app_config::to_json() const -> nlohmann::json {
data[JSON_API_PORT] = api_port_; data[JSON_API_PORT] = api_port_;
data[JSON_API_USER] = api_user_; data[JSON_API_USER] = api_user_;
data[JSON_AUTO_START] = auto_start_; data[JSON_AUTO_START] = auto_start_;
data[JSON_EVENT_LEVEL] = event_level_to_string(event_level_);
data[JSON_MOUNT_AUTO_START] = map_to_json(mount_auto_start_); data[JSON_MOUNT_AUTO_START] = map_to_json(mount_auto_start_);
data[JSON_MOUNT_LOCATIONS] = map_to_json(locations_); data[JSON_MOUNT_LOCATIONS] = map_to_json(locations_);
return data; return data;

View File

@@ -111,14 +111,6 @@ namespace {
return errno; return errno;
#endif // defined(_WIN32) #endif // defined(_WIN32)
} }
[[nodiscard]] auto is_addr_in_use(int err) -> bool {
#if defined(_WIN32)
return err == WSAEADDRINUSE;
#else // !defined(_WIN32)
return err == EADDRINUSE;
#endif // defined(_WIN32)
}
} // namespace } // namespace
namespace repertory::ui { namespace repertory::ui {