3 Commits

Author SHA1 Message Date
df60ac8dfc unit tests and fixes
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
2024-12-20 18:39:10 -06:00
a9be30e6e7 unit tests and fixes 2024-12-20 18:27:45 -06:00
b65c9d2ab7 unit tests and fixes 2024-12-20 18:24:11 -06:00
3 changed files with 23 additions and 12 deletions

View File

@ -115,16 +115,7 @@ private:
[[nodiscard]] auto load() -> bool; [[nodiscard]] auto load() -> bool;
template <typename dest, typename source> template <typename dest, typename source>
auto set_value(dest &dst, const source &src) -> bool { auto set_value(dest &dst, const source &src) -> bool;
if (dst.load() == src) {
return false;
}
dst = src;
config_changed_ = true;
save();
return true;
}
public: public:
[[nodiscard]] auto get_api_auth() const -> std::string; [[nodiscard]] auto get_api_auth() const -> std::string;

View File

@ -41,7 +41,8 @@ constexpr const auto default_task_wait_ms{100U};
constexpr const auto default_timeout_ms{60000U}; constexpr const auto default_timeout_ms{60000U};
constexpr const auto max_orphaned_file_retention_days{std::uint16_t(31U)}; constexpr const auto max_orphaned_file_retention_days{std::uint16_t(31U)};
constexpr const auto max_ring_buffer_file_size{std::uint16_t(1024U)}; constexpr const auto max_ring_buffer_file_size{std::uint16_t(1024U)};
constexpr const auto min_cache_size_bytes{100UL * 1024UL * 1024UL}; constexpr const auto min_cache_size_bytes{
std::uint64_t(100UL * 1024UL * 1024UL)};
constexpr const auto min_download_timeout_secs{std::uint8_t(5U)}; constexpr const auto min_download_timeout_secs{std::uint8_t(5U)};
constexpr const auto min_online_check_retry_secs{std::uint16_t(15U)}; constexpr const auto min_online_check_retry_secs{std::uint16_t(15U)};
constexpr const auto min_orphaned_file_retention_days{std::uint16_t(1U)}; constexpr const auto min_orphaned_file_retention_days{std::uint16_t(1U)};

View File

@ -93,6 +93,10 @@ app_config::app_config(const provider_type &prov,
host_cfg.api_port = default_api_port(prov_); host_cfg.api_port = default_api_port(prov_);
set_host_config(host_cfg); set_host_config(host_cfg);
auto rm_cfg = get_remote_mount();
rm_cfg.api_port = default_remote_api_port(prov);
set_remote_mount(rm_cfg);
if (not utils::file::directory(data_directory_).create_directory()) { if (not utils::file::directory(data_directory_).create_directory()) {
throw startup_exception( throw startup_exception(
fmt::format("unable to create data directory|sp|{}", data_directory_)); fmt::format("unable to create data directory|sp|{}", data_directory_));
@ -1101,7 +1105,7 @@ void app_config::save() {
recur_mutex_lock lock(read_write_mutex_); recur_mutex_lock lock(read_write_mutex_);
auto file_path = get_config_file_path(); auto file_path = get_config_file_path();
if (not(config_changed_ || utils::file::file(file_path).exists())) { if (not config_changed_ && utils::file::file(file_path).exists()) {
return; return;
} }
@ -1235,9 +1239,24 @@ void app_config::set_sia_config(sia_config value) {
} }
void app_config::set_task_wait_ms(std::uint16_t value) { void app_config::set_task_wait_ms(std::uint16_t value) {
std::cout << task_wait_ms_.load() << '|' << value << std::endl;
set_value(task_wait_ms_, value); set_value(task_wait_ms_, value);
} }
template <typename dest, typename source>
auto app_config::set_value(dest &dst, const source &src) -> bool {
if (dst.load() == src) {
return false;
}
std::cout << "changed" << std::endl;
dst = src;
config_changed_ = true;
save();
return true;
}
auto app_config::set_value_by_name(const std::string &name, auto app_config::set_value_by_name(const std::string &name,
const std::string &value) -> std::string { const std::string &value) -> std::string {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();