Timeouts should be treated as integer here
It's not a double in the settings. It gets casted into a double later, but it's not like you can set 3.528 in the settings.
This commit is contained in:
parent
d19b81a54e
commit
2e25008de3
3 changed files with 18 additions and 21 deletions
|
@ -31,6 +31,8 @@
|
|||
namespace duck {
|
||||
|
||||
namespace {
|
||||
constexpr const std::size_t g_min_update_timeout = 60;
|
||||
|
||||
constexpr const char g_db_path_sect[] = "system";
|
||||
constexpr const char g_db_path[] = "db_path";
|
||||
|
||||
|
@ -90,11 +92,6 @@ namespace {
|
|||
);
|
||||
}
|
||||
|
||||
double to_double (std::string_view val) {
|
||||
const auto seconds = dhandy::int_conv<unsigned int>(val);
|
||||
return static_cast<double>(seconds);
|
||||
}
|
||||
|
||||
std::string whole_ini() {
|
||||
std::ifstream input(g_config_file_path);
|
||||
input >> std::noskipws;
|
||||
|
@ -188,24 +185,24 @@ bool AppConfig::store_raw_json() const {
|
|||
return to_bool(val);
|
||||
}
|
||||
|
||||
double AppConfig::items_timeout() const {
|
||||
std::size_t AppConfig::items_timeout() const {
|
||||
std::string_view val = value_ifp(m_ini, g_items_time_sect, g_items_time, g_items_time_def, false);
|
||||
return to_double(val);
|
||||
return std::max(dhandy::int_conv<std::size_t>(val), g_min_update_timeout);
|
||||
}
|
||||
|
||||
double AppConfig::icons_timeout() const {
|
||||
std::size_t AppConfig::icons_timeout() const {
|
||||
std::string_view val = value_ifp(m_ini, g_icons_time_sect, g_icons_time, g_icons_time_def, false);
|
||||
return to_double(val);
|
||||
return std::max(dhandy::int_conv<std::size_t>(val), g_min_update_timeout);
|
||||
}
|
||||
|
||||
double AppConfig::shops_timeout() const {
|
||||
std::size_t AppConfig::shops_timeout() const {
|
||||
std::string_view val = value_ifp(m_ini, g_shops_time_sect, g_shops_time, g_shops_time_def, false);
|
||||
return to_double(val);
|
||||
return std::max(dhandy::int_conv<std::size_t>(val), g_min_update_timeout);
|
||||
}
|
||||
|
||||
double AppConfig::creators_timeout() const {
|
||||
std::size_t AppConfig::creators_timeout() const {
|
||||
std::string_view val = value_ifp(m_ini, g_creators_time_sect, g_creators_time, g_creators_time_def, false);
|
||||
return to_double(val);
|
||||
return std::max(dhandy::int_conv<std::size_t>(val), g_min_update_timeout);
|
||||
}
|
||||
|
||||
} //namespace duck
|
||||
|
|
|
@ -35,10 +35,10 @@ public:
|
|||
std::string_view backend() const;
|
||||
bool store_raw_json() const;
|
||||
|
||||
double items_timeout() const;
|
||||
double icons_timeout() const;
|
||||
double shops_timeout() const;
|
||||
double creators_timeout() const;
|
||||
std::size_t items_timeout() const;
|
||||
std::size_t icons_timeout() const;
|
||||
std::size_t shops_timeout() const;
|
||||
std::size_t creators_timeout() const;
|
||||
|
||||
private:
|
||||
kamokan::IniFile m_ini;
|
||||
|
|
|
@ -74,10 +74,10 @@ void test(oro::Api* api, oro::OriginsDB* db, const AppConfig& app_conf) {
|
|||
auto sig_int = worker.make_event<SignalInt>(&worker);
|
||||
const bool rj = app_conf.store_raw_json();
|
||||
|
||||
const double w1 = app_conf.items_timeout();
|
||||
const double w2 = app_conf.icons_timeout();
|
||||
const double w3 = app_conf.shops_timeout();
|
||||
const double w4 = app_conf.creators_timeout();
|
||||
const double w1 = static_cast<double>(app_conf.items_timeout());
|
||||
const double w2 = static_cast<double>(app_conf.icons_timeout());
|
||||
const double w3 = static_cast<double>(app_conf.shops_timeout());
|
||||
const double w4 = static_cast<double>(app_conf.creators_timeout());
|
||||
|
||||
auto timer_items = worker.make_event<TimerItems>(TSet{w1, ed, rj}, &pool, api, db);
|
||||
auto timer_icons = worker.make_event<TimerIcons>(TSet{w2, ed, rj}, &pool, api, db);
|
||||
|
|
Loading…
Reference in a new issue