Commit 91729437 authored by Max Kellermann's avatar Max Kellermann

Main: initialize Database before Storage

parent 3af7af0b
...@@ -172,7 +172,6 @@ glue_db_init_and_load(void) ...@@ -172,7 +172,6 @@ glue_db_init_and_load(void)
Error error; Error error;
instance->database = instance->database =
CreateConfiguredDatabase(*instance->event_loop, *instance, CreateConfiguredDatabase(*instance->event_loop, *instance,
instance->storage != nullptr,
is_simple, error); is_simple, error);
if (instance->database == nullptr) { if (instance->database == nullptr) {
if (error.IsDefined()) if (error.IsDefined())
...@@ -181,6 +180,18 @@ glue_db_init_and_load(void) ...@@ -181,6 +180,18 @@ glue_db_init_and_load(void)
return true; return true;
} }
if (!InitStorage(error))
FatalError(error);
if (instance->storage == nullptr) {
delete instance->database;
instance->database = nullptr;
LogDefault(config_domain,
"Found database setting without "
"music_directory - disabling database");
return true;
}
if (!instance->database->Open(error)) if (!instance->database->Open(error))
FatalError(error); FatalError(error);
...@@ -199,10 +210,6 @@ glue_db_init_and_load(void) ...@@ -199,10 +210,6 @@ glue_db_init_and_load(void)
static bool static bool
InitDatabaseAndStorage() InitDatabaseAndStorage()
{ {
Error error;
if (!InitStorage(error))
FatalError(error);
const bool create_db = !glue_db_init_and_load(); const bool create_db = !glue_db_init_and_load();
return create_db; return create_db;
} }
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
Database * Database *
CreateConfiguredDatabase(EventLoop &loop, DatabaseListener &listener, CreateConfiguredDatabase(EventLoop &loop, DatabaseListener &listener,
bool have_storage, bool &is_simple_r, Error &error) bool &is_simple_r, Error &error)
{ {
const struct config_param *param = config_get_param(CONF_DATABASE); const struct config_param *param = config_get_param(CONF_DATABASE);
const struct config_param *path = config_get_param(CONF_DB_FILE); const struct config_param *path = config_get_param(CONF_DB_FILE);
...@@ -40,18 +40,6 @@ CreateConfiguredDatabase(EventLoop &loop, DatabaseListener &listener, ...@@ -40,18 +40,6 @@ CreateConfiguredDatabase(EventLoop &loop, DatabaseListener &listener,
return nullptr; return nullptr;
} }
if (!have_storage) {
if (param != nullptr)
LogDefault(config_domain,
"Found database setting without "
"music_directory - disabling database");
if (path != nullptr)
LogDefault(config_domain,
"Found db_file setting without "
"music_directory - disabling database");
return nullptr;
}
struct config_param *allocated = nullptr; struct config_param *allocated = nullptr;
if (param == nullptr && path != nullptr) { if (param == nullptr && path != nullptr) {
......
...@@ -34,6 +34,6 @@ class Error; ...@@ -34,6 +34,6 @@ class Error;
*/ */
Database * Database *
CreateConfiguredDatabase(EventLoop &loop, DatabaseListener &listener, CreateConfiguredDatabase(EventLoop &loop, DatabaseListener &listener,
bool have_storage, bool &is_simple_r, Error &error); bool &is_simple_r, Error &error);
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment