DatabaseGlue: pass block to db_init()

Let the caller take care for legacy conversion.
This commit is contained in:
Max Kellermann 2012-08-08 08:36:14 +02:00
parent aa55d759f5
commit b46bb611b3
3 changed files with 9 additions and 13 deletions

View File

@ -51,21 +51,12 @@ static Database *db;
static bool db_is_open; static bool db_is_open;
bool bool
db_init(const struct config_param *path, GError **error_r) db_init(const struct config_param *param, GError **error_r)
{ {
assert(db == NULL); assert(db == NULL);
assert(!db_is_open); assert(!db_is_open);
if (path == NULL)
return true;
struct config_param *param = config_new_param("database", path->line);
config_add_block_param(param, "path", path->value, path->line);
db = simple_db_plugin.create(param, error_r); db = simple_db_plugin.create(param, error_r);
config_param_free(param);
return db != NULL; return db != NULL;
} }

View File

@ -35,10 +35,10 @@ struct db_visitor;
/** /**
* Initialize the database library. * Initialize the database library.
* *
* @param path the absolute path of the database file * @param param the database configuration block
*/ */
bool bool
db_init(const struct config_param *path, GError **error_r); db_init(const struct config_param *param, GError **error_r);
void void
db_finish(void); db_finish(void);

View File

@ -169,9 +169,14 @@ glue_db_init_and_load(void)
if (path == NULL) if (path == NULL)
MPD_ERROR(CONF_DB_FILE " setting missing"); MPD_ERROR(CONF_DB_FILE " setting missing");
if (!db_init(path, &error)) struct config_param *param = config_new_param("database", path->line);
config_add_block_param(param, "path", path->value, path->line);
if (!db_init(param, &error))
MPD_ERROR("%s", error->message); MPD_ERROR("%s", error->message);
config_param_free(param);
ret = db_load(&error); ret = db_load(&error);
if (!ret) if (!ret)
MPD_ERROR("%s", error->message); MPD_ERROR("%s", error->message);