Commit b4430839 authored by Max Kellermann's avatar Max Kellermann

database: generate GError when database is disabled

parent 412cf974
......@@ -395,6 +395,12 @@ print_error(struct client *client, GError *error)
return print_playlist_result(client, result);
} else if (error->domain == db_quark()) {
switch ((enum db_error)error->code) {
case DB_DISABLED:
command_error(client, ACK_ERROR_NO_EXIST, "%s",
error->message);
g_error_free(error);
return COMMAND_RETURN_ERROR;
case DB_NOT_FOUND:
g_error_free(error);
command_error(client, ACK_ERROR_NO_EXIST, "Not found");
......
......@@ -27,6 +27,7 @@
#include "directory.h"
#include "stats.h"
#include "conf.h"
#include "glib_compat.h"
#include <glib.h>
......@@ -112,12 +113,14 @@ db_walk(const char *uri,
const struct db_visitor *visitor, void *ctx,
GError **error_r)
{
struct directory *directory;
if (db == NULL)
return -1;
if (db == NULL) {
g_set_error_literal(error_r, db_quark(), DB_DISABLED,
"No database");
return false;
}
if ((directory = db_get_directory(uri)) == NULL) {
struct directory *directory = db_get_directory(uri);
if (directory == NULL) {
struct song *song;
if (visitor->song != NULL &&
(song = db_get_song(uri)) != NULL)
......
......@@ -23,6 +23,12 @@
#include <glib.h>
enum db_error {
/**
* The database is disabled, i.e. none is configured in this
* MPD instance.
*/
DB_DISABLED,
DB_NOT_FOUND,
};
......
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