From ad866f7a7d4dd02f5f109f04f20eea3aab14fb5a Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 17 Jul 2018 22:41:28 +0200 Subject: [PATCH] db/update/Config: use struct ConfigData --- src/Main.cxx | 11 ++++++----- src/db/update/Config.cxx | 14 ++++++++------ src/db/update/Config.hxx | 4 +++- src/db/update/Service.cxx | 6 ++++-- src/db/update/Service.hxx | 3 ++- 5 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/Main.cxx b/src/Main.cxx index d3ade091c..e2eb7e920 100644 --- a/src/Main.cxx +++ b/src/Main.cxx @@ -181,7 +181,7 @@ InitStorage(EventLoop &event_loop) * process has been daemonized. */ static bool -glue_db_init_and_load(void) +glue_db_init_and_load(const ConfigData &config) { instance->database = CreateConfiguredDatabase(instance->event_loop, @@ -218,7 +218,8 @@ glue_db_init_and_load(void) return true; SimpleDatabase &db = *(SimpleDatabase *)instance->database; - instance->update = new UpdateService(instance->event_loop, db, + instance->update = new UpdateService(config, + instance->event_loop, db, static_cast(*instance->storage), *instance); @@ -227,9 +228,9 @@ glue_db_init_and_load(void) } static bool -InitDatabaseAndStorage() +InitDatabaseAndStorage(const ConfigData &config) { - const bool create_db = !glue_db_init_and_load(); + const bool create_db = !glue_db_init_and_load(config); return create_db; } @@ -555,7 +556,7 @@ try { decoder_plugin_init_all(GetGlobalConfig()); #ifdef ENABLE_DATABASE - const bool create_db = InitDatabaseAndStorage(); + const bool create_db = InitDatabaseAndStorage(GetGlobalConfig()); #endif glue_sticker_init(); diff --git a/src/db/update/Config.cxx b/src/db/update/Config.cxx index c2b66e67e..e931391c3 100644 --- a/src/db/update/Config.cxx +++ b/src/db/update/Config.cxx @@ -19,18 +19,20 @@ #include "config.h" #include "Config.hxx" -#include "config/Global.hxx" +#include "config/Data.hxx" #include "config/Option.hxx" -UpdateConfig::UpdateConfig() +UpdateConfig::UpdateConfig(const ConfigData &config) { #ifndef _WIN32 follow_inside_symlinks = - config_get_bool(ConfigOption::FOLLOW_INSIDE_SYMLINKS, - DEFAULT_FOLLOW_INSIDE_SYMLINKS); + config.GetBool(ConfigOption::FOLLOW_INSIDE_SYMLINKS, + DEFAULT_FOLLOW_INSIDE_SYMLINKS); follow_outside_symlinks = - config_get_bool(ConfigOption::FOLLOW_OUTSIDE_SYMLINKS, - DEFAULT_FOLLOW_OUTSIDE_SYMLINKS); + config.GetBool(ConfigOption::FOLLOW_OUTSIDE_SYMLINKS, + DEFAULT_FOLLOW_OUTSIDE_SYMLINKS); +#else + (void)config; #endif } diff --git a/src/db/update/Config.hxx b/src/db/update/Config.hxx index 955ecf502..a8ed9859c 100644 --- a/src/db/update/Config.hxx +++ b/src/db/update/Config.hxx @@ -22,6 +22,8 @@ #include "check.h" +struct ConfigData; + struct UpdateConfig { #ifndef _WIN32 static constexpr bool DEFAULT_FOLLOW_INSIDE_SYMLINKS = true; @@ -31,7 +33,7 @@ struct UpdateConfig { bool follow_outside_symlinks = DEFAULT_FOLLOW_OUTSIDE_SYMLINKS; #endif - UpdateConfig(); + explicit UpdateConfig(const ConfigData &config); }; #endif diff --git a/src/db/update/Service.cxx b/src/db/update/Service.cxx index f39cc76ea..9f7211933 100644 --- a/src/db/update/Service.cxx +++ b/src/db/update/Service.cxx @@ -38,10 +38,12 @@ #include -UpdateService::UpdateService(EventLoop &_loop, SimpleDatabase &_db, +UpdateService::UpdateService(const ConfigData &_config, + EventLoop &_loop, SimpleDatabase &_db, CompositeStorage &_storage, DatabaseListener &_listener) - :defer(_loop, BIND_THIS_METHOD(RunDeferred)), + :config(_config), + defer(_loop, BIND_THIS_METHOD(RunDeferred)), db(_db), storage(_storage), listener(_listener), update_thread(BIND_THIS_METHOD(Task)) diff --git a/src/db/update/Service.hxx b/src/db/update/Service.hxx index 7fdfa4c7a..e8818fd46 100644 --- a/src/db/update/Service.hxx +++ b/src/db/update/Service.hxx @@ -60,7 +60,8 @@ class UpdateService final { UpdateWalk *walk = nullptr; public: - UpdateService(EventLoop &_loop, SimpleDatabase &_db, + UpdateService(const ConfigData &_config, + EventLoop &_loop, SimpleDatabase &_db, CompositeStorage &_storage, DatabaseListener &_listener);