Commit 4b010df9 authored by Max Kellermann's avatar Max Kellermann

Main: create Storage instance in glue_mapper_init()

Don't use the obsolete Mapper library to create it.
parent 5e4dd4be
...@@ -145,6 +145,16 @@ glue_mapper_init(Error &error) ...@@ -145,6 +145,16 @@ glue_mapper_init(Error &error)
if (music_dir.IsNull()) if (music_dir.IsNull())
music_dir = GetUserMusicDir(); music_dir = GetUserMusicDir();
#ifdef ENABLE_DATABASE
if (!music_dir.IsNull()) {
const auto music_dir_utf8 = music_dir.ToUTF8();
assert(!music_dir_utf8.empty());
instance->storage = CreateLocalStorage(music_dir_utf8.c_str(),
music_dir);
}
#endif
mapper_init(std::move(music_dir), std::move(playlist_dir)); mapper_init(std::move(music_dir), std::move(playlist_dir));
return true; return true;
} }
...@@ -166,7 +176,7 @@ glue_db_init_and_load(void) ...@@ -166,7 +176,7 @@ glue_db_init_and_load(void)
LogWarning(main_domain, LogWarning(main_domain,
"Found both 'database' and 'db_file' setting - ignoring the latter"); "Found both 'database' and 'db_file' setting - ignoring the latter");
if (!mapper_has_music_directory()) { if (instance->storage == nullptr) {
if (param != nullptr) if (param != nullptr)
LogDefault(main_domain, LogDefault(main_domain,
"Found database setting without " "Found database setting without "
...@@ -207,8 +217,6 @@ glue_db_init_and_load(void) ...@@ -207,8 +217,6 @@ glue_db_init_and_load(void)
return true; return true;
SimpleDatabase &db = *(SimpleDatabase *)instance->database; SimpleDatabase &db = *(SimpleDatabase *)instance->database;
instance->storage = CreateLocalStorage(mapper_get_music_directory_utf8(),
mapper_get_music_directory_fs());
instance->update = new UpdateService(*instance->event_loop, db, instance->update = new UpdateService(*instance->event_loop, db,
*instance->storage, *instance->storage,
*instance); *instance);
...@@ -524,8 +532,7 @@ int mpd_main(int argc, char *argv[]) ...@@ -524,8 +532,7 @@ int mpd_main(int argc, char *argv[])
if (config_get_bool(CONF_AUTO_UPDATE, false)) { if (config_get_bool(CONF_AUTO_UPDATE, false)) {
#ifdef ENABLE_INOTIFY #ifdef ENABLE_INOTIFY
if (mapper_has_music_directory() && if (instance->storage != nullptr &&
instance->storage != nullptr &&
instance->update != nullptr) instance->update != nullptr)
mpd_inotify_init(*instance->event_loop, mpd_inotify_init(*instance->event_loop,
*instance->storage, *instance->storage,
......
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