db/update/Config: use struct ConfigData
This commit is contained in:
		
							
								
								
									
										11
									
								
								src/Main.cxx
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								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<CompositeStorage &>(*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(); | ||||
|   | ||||
| @@ -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 | ||||
| } | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -38,10 +38,12 @@ | ||||
|  | ||||
| #include <assert.h> | ||||
|  | ||||
| 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)) | ||||
|   | ||||
| @@ -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); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Max Kellermann
					Max Kellermann