Compare commits
3 Commits
f333b74cd1
...
df60ac8dfc
Author | SHA1 | Date | |
---|---|---|---|
df60ac8dfc | |||
a9be30e6e7 | |||
b65c9d2ab7 |
@ -115,16 +115,7 @@ private:
|
||||
[[nodiscard]] auto load() -> bool;
|
||||
|
||||
template <typename dest, typename source>
|
||||
auto set_value(dest &dst, const source &src) -> bool {
|
||||
if (dst.load() == src) {
|
||||
return false;
|
||||
}
|
||||
|
||||
dst = src;
|
||||
config_changed_ = true;
|
||||
save();
|
||||
return true;
|
||||
}
|
||||
auto set_value(dest &dst, const source &src) -> bool;
|
||||
|
||||
public:
|
||||
[[nodiscard]] auto get_api_auth() const -> std::string;
|
||||
|
@ -41,7 +41,8 @@ constexpr const auto default_task_wait_ms{100U};
|
||||
constexpr const auto default_timeout_ms{60000U};
|
||||
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 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_online_check_retry_secs{std::uint16_t(15U)};
|
||||
constexpr const auto min_orphaned_file_retention_days{std::uint16_t(1U)};
|
||||
|
@ -93,6 +93,10 @@ app_config::app_config(const provider_type &prov,
|
||||
host_cfg.api_port = default_api_port(prov_);
|
||||
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()) {
|
||||
throw startup_exception(
|
||||
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_);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -1235,9 +1239,24 @@ void app_config::set_sia_config(sia_config 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);
|
||||
}
|
||||
|
||||
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,
|
||||
const std::string &value) -> std::string {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
Reference in New Issue
Block a user