db/update/Config: use struct ConfigData
This commit is contained in:
parent
338a6f2a96
commit
ad866f7a7d
11
src/Main.cxx
11
src/Main.cxx
@ -181,7 +181,7 @@ InitStorage(EventLoop &event_loop)
|
|||||||
* process has been daemonized.
|
* process has been daemonized.
|
||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
glue_db_init_and_load(void)
|
glue_db_init_and_load(const ConfigData &config)
|
||||||
{
|
{
|
||||||
instance->database =
|
instance->database =
|
||||||
CreateConfiguredDatabase(instance->event_loop,
|
CreateConfiguredDatabase(instance->event_loop,
|
||||||
@ -218,7 +218,8 @@ glue_db_init_and_load(void)
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
SimpleDatabase &db = *(SimpleDatabase *)instance->database;
|
SimpleDatabase &db = *(SimpleDatabase *)instance->database;
|
||||||
instance->update = new UpdateService(instance->event_loop, db,
|
instance->update = new UpdateService(config,
|
||||||
|
instance->event_loop, db,
|
||||||
static_cast<CompositeStorage &>(*instance->storage),
|
static_cast<CompositeStorage &>(*instance->storage),
|
||||||
*instance);
|
*instance);
|
||||||
|
|
||||||
@ -227,9 +228,9 @@ glue_db_init_and_load(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
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;
|
return create_db;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -555,7 +556,7 @@ try {
|
|||||||
decoder_plugin_init_all(GetGlobalConfig());
|
decoder_plugin_init_all(GetGlobalConfig());
|
||||||
|
|
||||||
#ifdef ENABLE_DATABASE
|
#ifdef ENABLE_DATABASE
|
||||||
const bool create_db = InitDatabaseAndStorage();
|
const bool create_db = InitDatabaseAndStorage(GetGlobalConfig());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
glue_sticker_init();
|
glue_sticker_init();
|
||||||
|
@ -19,18 +19,20 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "Config.hxx"
|
#include "Config.hxx"
|
||||||
#include "config/Global.hxx"
|
#include "config/Data.hxx"
|
||||||
#include "config/Option.hxx"
|
#include "config/Option.hxx"
|
||||||
|
|
||||||
UpdateConfig::UpdateConfig()
|
UpdateConfig::UpdateConfig(const ConfigData &config)
|
||||||
{
|
{
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
follow_inside_symlinks =
|
follow_inside_symlinks =
|
||||||
config_get_bool(ConfigOption::FOLLOW_INSIDE_SYMLINKS,
|
config.GetBool(ConfigOption::FOLLOW_INSIDE_SYMLINKS,
|
||||||
DEFAULT_FOLLOW_INSIDE_SYMLINKS);
|
DEFAULT_FOLLOW_INSIDE_SYMLINKS);
|
||||||
|
|
||||||
follow_outside_symlinks =
|
follow_outside_symlinks =
|
||||||
config_get_bool(ConfigOption::FOLLOW_OUTSIDE_SYMLINKS,
|
config.GetBool(ConfigOption::FOLLOW_OUTSIDE_SYMLINKS,
|
||||||
DEFAULT_FOLLOW_OUTSIDE_SYMLINKS);
|
DEFAULT_FOLLOW_OUTSIDE_SYMLINKS);
|
||||||
|
#else
|
||||||
|
(void)config;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
|
|
||||||
#include "check.h"
|
#include "check.h"
|
||||||
|
|
||||||
|
struct ConfigData;
|
||||||
|
|
||||||
struct UpdateConfig {
|
struct UpdateConfig {
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
static constexpr bool DEFAULT_FOLLOW_INSIDE_SYMLINKS = true;
|
static constexpr bool DEFAULT_FOLLOW_INSIDE_SYMLINKS = true;
|
||||||
@ -31,7 +33,7 @@ struct UpdateConfig {
|
|||||||
bool follow_outside_symlinks = DEFAULT_FOLLOW_OUTSIDE_SYMLINKS;
|
bool follow_outside_symlinks = DEFAULT_FOLLOW_OUTSIDE_SYMLINKS;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
UpdateConfig();
|
explicit UpdateConfig(const ConfigData &config);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -38,10 +38,12 @@
|
|||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
UpdateService::UpdateService(EventLoop &_loop, SimpleDatabase &_db,
|
UpdateService::UpdateService(const ConfigData &_config,
|
||||||
|
EventLoop &_loop, SimpleDatabase &_db,
|
||||||
CompositeStorage &_storage,
|
CompositeStorage &_storage,
|
||||||
DatabaseListener &_listener)
|
DatabaseListener &_listener)
|
||||||
:defer(_loop, BIND_THIS_METHOD(RunDeferred)),
|
:config(_config),
|
||||||
|
defer(_loop, BIND_THIS_METHOD(RunDeferred)),
|
||||||
db(_db), storage(_storage),
|
db(_db), storage(_storage),
|
||||||
listener(_listener),
|
listener(_listener),
|
||||||
update_thread(BIND_THIS_METHOD(Task))
|
update_thread(BIND_THIS_METHOD(Task))
|
||||||
|
@ -60,7 +60,8 @@ class UpdateService final {
|
|||||||
UpdateWalk *walk = nullptr;
|
UpdateWalk *walk = nullptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UpdateService(EventLoop &_loop, SimpleDatabase &_db,
|
UpdateService(const ConfigData &_config,
|
||||||
|
EventLoop &_loop, SimpleDatabase &_db,
|
||||||
CompositeStorage &_storage,
|
CompositeStorage &_storage,
|
||||||
DatabaseListener &_listener);
|
DatabaseListener &_listener);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user