aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2011-09-05 23:03:05 +0200
committerMax Kellermann <max@duempel.org>2011-09-10 07:58:43 +0200
commit7819aa6b2060b600b9ec2471f250038eeebae523 (patch)
treea1523f90ee693f5adba207c208bea81b8466e3b9 /src/main.c
parent7cc6b63aac5a355bc2dd216d41ce4dc0e0fc3066 (diff)
downloadmpd-7819aa6b2060b600b9ec2471f250038eeebae523.tar.gz
mpd-7819aa6b2060b600b9ec2471f250038eeebae523.tar.xz
mpd-7819aa6b2060b600b9ec2471f250038eeebae523.zip
db_plugin: introducing a plugin API for the song database
First draft, not really pluggable currently - hard-coded to use the "simple" plugin, and calls several of its internal functions. The API is very simple currently, all searches are still performed over the root "directory" object. Future changes to the API will move those search implementations into the plugin, to allow more efficient implementations, or implementations that don't have the whole tree in memory all the time.
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c31
1 files changed, 9 insertions, 22 deletions
diff --git a/src/main.c b/src/main.c
index e73f5ade0..49ce6e125 100644
--- a/src/main.c
+++ b/src/main.c
@@ -156,44 +156,31 @@ glue_mapper_init(GError **error_r)
static bool
glue_db_init_and_load(void)
{
- GError *error = NULL;
- char *path = config_dup_path(CONF_DB_FILE, &error);
- if (path == NULL && error != NULL)
- MPD_ERROR("%s", error->message);
+ const struct config_param *path = config_get_param(CONF_DB_FILE);
+ GError *error = NULL;
bool ret;
if (!mapper_has_music_directory()) {
- g_free(path);
if (path != NULL)
g_message("Found " CONF_DB_FILE " setting without "
CONF_MUSIC_DIR " - disabling database");
- db_init(NULL);
+ db_init(NULL, NULL);
return true;
}
if (path == NULL)
MPD_ERROR(CONF_DB_FILE " setting missing");
- db_init(path);
- g_free(path);
+ if (!db_init(path, &error))
+ MPD_ERROR("%s", error->message);
ret = db_load(&error);
- if (!ret) {
- g_warning("Failed to load database: %s", error->message);
- g_error_free(error);
- error = NULL;
-
- if (!db_check(&error))
- MPD_ERROR("%s", error->message);
-
- db_clear();
-
- /* run database update after daemonization */
- return false;
- }
+ if (!ret)
+ MPD_ERROR("%s", error->message);
- return true;
+ /* run database update after daemonization? */
+ return db_exists();
}
/**